Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/forms/dist/components/select.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions packages/forms/resources/js/components/select.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Select } from '../../../../support/resources/js/utilities/select.js'

export default function selectFormComponent({
extraInputAttributes,
canOptionLabelsWrap,
canSelectPlaceholder,
isHtmlAllowed,
Expand Down Expand Up @@ -44,6 +45,7 @@ export default function selectFormComponent({
options,
placeholder,
state: this.state,
extraInputAttributes,
canOptionLabelsWrap,
canSelectPlaceholder,
initialOptionLabel,
Expand Down
1 change: 1 addition & 0 deletions packages/forms/resources/views/components/select.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class="fi-hidden"
x-load
x-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('select', 'filament/forms') }}"
x-data="selectFormComponent({
extraInputAttributes: @js($extraInputAttributeBag->merge(['id'=>$id], escape: false)),
canOptionLabelsWrap: @js($canOptionLabelsWrap),
canSelectPlaceholder: @js($canSelectPlaceholder),
isHtmlAllowed: @js($isHtmlAllowed),
Expand Down
9 changes: 9 additions & 0 deletions packages/support/resources/js/utilities/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class Select {
options,
placeholder,
state,
extraInputAttributes = [],
canOptionLabelsWrap = true,
canSelectPlaceholder = true,
initialOptionLabel = null,
Expand Down Expand Up @@ -56,6 +57,7 @@ export class Select {
this.originalOptions = JSON.parse(JSON.stringify(options)) // Keep a copy of original options
this.placeholder = placeholder
this.state = state
this.extraInputAttributes = extraInputAttributes
this.canOptionLabelsWrap = canOptionLabelsWrap
this.canSelectPlaceholder = canSelectPlaceholder
this.initialOptionLabel = initialOptionLabel
Expand Down Expand Up @@ -148,6 +150,10 @@ export class Select {
this.selectButton.className = 'fi-select-input-btn'
this.selectButton.type = 'button'
this.selectButton.setAttribute('aria-expanded', 'false')
//loop through extraInputAttributes and set them on the selectButton
Object.entries(this.extraInputAttributes).forEach(([name, value]) => {
this.selectButton.setAttribute(name, value)
})

// Create the selected value display
this.selectedDisplay = document.createElement('div')
Expand Down Expand Up @@ -880,6 +886,9 @@ export class Select {
event.stopPropagation() // Prevent dropdown from toggling
this.selectOption('') // Select empty value to clear
})
Object.entries(this.extraInputAttributes).forEach(([name, value]) => {
removeButton.setAttribute(name, value)
})

// Add keydown event listener to handle space key
removeButton.addEventListener('keydown', (event) => {
Expand Down