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()
No description
No description
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?