© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•13mo ago•
1 reply
Darkavatar23

Change Focus Programmatically

is there a simple way that at the end of an action I can put the focus on a specific text box? using the default pages (create and edit) and not having to define a custom one and have AlpineJs intervene?
I tried to use autofocus and other tricks

https://cornel.co/article/focus-input-alpinejs#:~:text=To%20focus%20an%20input%20element,the%20standalone%20x%2Dinit%20directive.&text=However%2C%20if%20your%20input%20element,to%20use%20Alpine's%20%24nextTick%20function.

I tried to use extraAttribute but nothing, nothing that I can use


the snippet

$scannedAction = Action::make('Scansiona')
->icon('heroicon-o-plus')
->keyBindings(['Enter'])
->action(function ($get, $set, $livewire) {
// Recupera i barcode scansionati
$scannedBarcode = $get('scanned') ?? '';
//$scannedBarcodes = array_filter(array_map('trim', explode(' ', $scannedBarcodes)));

// Recupera il listino prezzi selezionato
$priceListId = $get('price_list_id');

if (!$priceListId) {
Notification::make()
->title('Errore')
->body('Devi selezionare un listino prezzi prima di scansionare.')->danger()
->send();
return;
}
// Array per salvare le righe attuali del repeater
$quotationLines = $get('quotation_lines') ?? [];
// Trova l'articolo nel listino prezzi
$articlePriceList = ArticlePriceList::with('article')
->where('price_list_id', $priceListId)
.......
some other operation , and then i want the focus on this
Forms\Components\TextInput::make('scanned')
->label('Aggiungi Articoli')
->suffixAction($scannedAction)
->autofocus(true)
->columnSpan(3),

i guess im missing something like $set('scanned')->focus()
image.png
image.png
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Programmatically change active Tab
FilamentFFilament / ❓┊help
7mo ago
Change repeater items programmatically
FilamentFFilament / ❓┊help
3y ago
Focus another select after change
FilamentFFilament / ❓┊help
2y ago
is it possible to change logo programmatically?
FilamentFFilament / ❓┊help
3y ago