Autofocus after submitting form

I make a custom page and render filament form as below
public function form(Form $form): Form
    {
        return $form
            ->schema([
                Select::make('product_id')
                ->searchable()
                ->autofocus()
                ->label('Search Product')
                ->getSearchResultsUsing(fn (string $search): array => Product::where('product_name', 'like', "%{$search}%")
                    ->orWhere('barcode', 'like', "%{$search}%")
                    ->limit(20)->pluck('product_name', 'id')->toArray())
                ->noSearchResultsMessage('No products found.')
                ->searchPrompt('Search by name or barcode')
                ->searchingMessage('Searching products...')
                ->required()
                ->native(false),
                TextInput::make('quantity')
                ->label('quantity')
                ->numeric()
                ->default(1)
                ->required(),
            ])->columns(2)
            ->statePath('data');
    }

And handle the form submission as below
 public function save(): void
    {
        try {
            $data = $this->form->getState();
            $product = Product::find($data['product_id']);
            $data = [
                'user_id'=> auth()->user()->id,
                'product_id' => $product->id,
                'quantity'  => $data['quantity'],
                'cost_price'=>$product->cost_price,
                'selling_price' => $product->selling_price,
                'discount' =>0,
            ];
            SaleCart::create($data);
            $this->updateTotal();
            $this->form->fill();
        } catch (Halt $exception) {
            //throw $th;
        }
    }

When first loading the page the autofocus on Select works well but after submitting and handling with save how can i make select be autofocus again. Is there is a filament way of handling this.
Was this page helpful?