-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added AlpineJs support for keyboard events
- Arrow key navigation between options - Enter key for selection - Enter/Space keys for reset - Tab for navigation - Added focus on search reset
- Loading branch information
1 parent
5a46a7a
commit 00d5389
Showing
7 changed files
with
91 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
<div | ||
class="{{ $styles['searchOptionItem'] }}" | ||
|
||
wire:click.stop="selectValue('{{ $option['value'] }}')" | ||
|
||
x-bind:class="{ 'bg-gray-100': selectedIndex === {{ $index }} }" | ||
x-on:mouseover="selectedIndex = {{ $index }}" | ||
> | ||
{{ $option['description'] }} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
<div | ||
id="selected-value" | ||
<button | ||
id="{{ $name }}-selected" | ||
type="button" | ||
class="{{ $styles['searchSelectedOption'] }}" | ||
|
||
x-on:keydown.enter.prevent="removeSelection(@this)" | ||
x-on:keydown.space.prevent="removeSelection(@this)" | ||
> | ||
<p class="{{ $styles['searchSelectedOptionTitle'] }}"> | ||
<span class="{{ $styles['searchSelectedOptionTitle'] }}"> | ||
{{ data_get($selectedOption, 'title', 'Override selectedOption method for a meaningful description') }} | ||
</p> | ||
</span> | ||
|
||
<button | ||
<span | ||
type="button" | ||
wire:click.stop="selectValue(null)" | ||
wire:click.prevent="selectValue(null)" | ||
> | ||
<svg class="{{ $styles['searchSelectedOptionReset'] }}" viewBox="0 0 20 20" fill="currentColor"> | ||
<path fill-rule="evenodd" | ||
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" | ||
clip-rule="evenodd" | ||
/> | ||
</svg> | ||
</button> | ||
</span> | ||
|
||
<input type="hidden" value="{{ $value }}" name="{{ $name }}"> | ||
|
||
</div> | ||
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters