F
Filament12mo ago
ericmp

Why the autofocus doesnt work on modals?

Why the autofocus doesnt work on modals? I open up the modal, but the text input is not focused, should be focused automatically, or i am wrong? if im wrong, how would be the workaround to achieve to be focused when the modal opens up?
Forms\Components\Select::make('genre')
->relationship(name: 'genre', titleAttribute: 'name')
->createOptionForm([
Forms\Components\TextInput::make('name')
->required()
->unique(Genre::class, 'name')
->autofocus()
,
])
,
Forms\Components\Select::make('genre')
->relationship(name: 'genre', titleAttribute: 'name')
->createOptionForm([
Forms\Components\TextInput::make('name')
->required()
->unique(Genre::class, 'name')
->autofocus()
,
])
,
2 Replies
awcodes
awcodes12mo ago
What other inputs are in the form? Modals by default use alpines trap focus so the first field should be auto focused by default, but I’ve noticed that other js based fields can break that functionality because they emit livewire requests which would cause inputs to loose focus.
ericmp
ericmpOP12mo ago
ohhh i found it out i have a select (Forms\Components\Select) which has: ->native(false) i removed the line ->native(false) and now autofocuses properly but idk which one i prefer i think i prefer the not native select component over the autofocus feature so im keeping it as i had it is this bug already reported?
Want results from more Discord servers?
Add your server