How can I call a Repeaters field 'add' action on enter in field?

I know this is probably not good UX as 'Enter' should submit the form. But I have a repeater with 2 fields per row, and when pressing ENTER in the last field (qty) I'd like to add a new empty line to the repeater. How could I do that?

I have now modified the Repeater's addAction using keyBindings, which kind of works but I want it to .focus on the first field on the next line. Is that even possible or how would I go about that? I have been fiddling with custom actions but no luck getting them to work.

If anybody could help me I would be grateful. Thank you!

Repeater code:

Repeater::make('products')->schema([
    Select::make('product'),
    TextInput::make('qty')
        ->numeric()
        ->step(1)
        ->minValue(0)
        ->required()
        ->minItems(1)
        ->hiddenLabel()
        ->addAction(
            fn(\Filament\Forms\Components\Actions\Action $action) => $action->keyBindings('enter')
        )
        ->addActionLabel(__('actions.add_line'))
        ->reorderable(false)
]);


ps I've "disabled" the default submit functions using the method mentioned here: https://github.com/filamentphp/filament/discussions/6067#discussioncomment-8036673
GitHub
Is there a solution that prevents submitting a form when pressing enter on a text box? Currently I couldn't find one, so this is what I came up: I created copies for create-record.blade.php and...
Was this page helpful?