F
Filament15mo ago
ElCoco

Can a suffixAction be triggered by pressing enter?

I have this form in a filament v3 Page:
public function form(Form $form): Form
{
return $form
->schema([
Components\TextInput::make('stuff')
->suffixAction(
Action::make('sendStuff')
->icon('heroicon-m-clipboard')
->action(function () {
$response = "Action triggered!"
})
),
Components\Textarea::make('response')
->rows(10),
]);
}
public function form(Form $form): Form
{
return $form
->schema([
Components\TextInput::make('stuff')
->suffixAction(
Action::make('sendStuff')
->icon('heroicon-m-clipboard')
->action(function () {
$response = "Action triggered!"
})
),
Components\Textarea::make('response')
->rows(10),
]);
}
I was expecting that the suffixAction will also be triggered by pressing the Enter key but is not the case. I could not find any mention to something like this in the Docs. I guess I am missing something very basic here...
2 Replies
Patrick Boivin
Patrick Boivin15mo ago
Pressing Enter will typically try to submit the form. I guess this is a personal preference but I don't think it's a good idea to break that expectation. I think you can do Tab + Enter to switch focus and trigger the action, if that makes sense.
ElCoco
ElCocoOP15mo ago
Yeah I understand that is not the common case than the suffix action is the same as submitting the form. But I really need the suffix action for mobile and still being able to submit it with enter in desktop. After all this is a chat application and there is only one input field. I was hopping for a way to overwrite the default behaviour. Seems like I would have to find a work around. Thanks for your reply!
Want results from more Discord servers?
Add your server