Skip to content

Commit

Permalink
fix: avoid search enter key submitting the form (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
mansoorkhan96 authored Apr 22, 2024
1 parent ac71cef commit 0c6c599
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
9 changes: 6 additions & 3 deletions src/Components/UnsplashPickerComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class UnsplashPickerComponent extends Component implements HasActions, HasForms
public function form(Form $form): Form
{
return $form
// ->columns(5)
// ->extraAttributes([''])
->schema([
Split::make([
TextInput::make('search')
Expand All @@ -45,7 +43,12 @@ public function form(Form $form): Form
->autocomplete(false)
->autofocus()
->grow()
->placeholder(__('unsplash-picker::unsplash-picker.search_for_an_image')),
->placeholder(__('unsplash-picker::unsplash-picker.search_for_an_image'))
->extraAlpineAttributes([
'x-on:keydown.enter' => 'if (!["TEXTAREA", "TRIX-EDITOR"].includes($event.target.tagName)) {
$event.preventDefault()
}',
]),

Toggle::make('useSquareDisplay')
->label(__('unsplash-picker::unsplash-picker.square_mode'))
Expand Down
24 changes: 19 additions & 5 deletions todo.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# TODO
- Support custom sizes that can be passed by user
- Add support for multipe uploads
- Add Full pagination
- Add support for Spatie Media Plugin
- Write tests
- Fix loading indicators
- Support custom sizes that can be passed by user
- Support more providers like pexels, bing images etc
- Add support for multipe uploads
- Add Full pagination
- Add support for Spatie Media Plugin

- CleanupUnusedUploadedFile should add support Spatie Media
- `$component->saveUploadedFiles()` saves the file to DB directly, which wouldnt work on create record page
- if dont run `$component->saveUploadedFiles()`, there is no way we can show a preview of uploaded file from url

We have two exceptions for adding support for spatie media

1. It can only be used on Edit record page and it would forcefully auto save the picked file.
2. User has to blindly save the form without viewing the preview.

Workaround:

- Write tests

0 comments on commit 0c6c599

Please sign in to comment.