-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AutoForm submits when pressing Return key, even in TextArea fields #2697
Comments
I haven't tested it, but I suspect that a workaround could be to add a simple key down listener to the text area that only does |
I tried something like this: const handleKeyDown = (event: React.KeyboardEvent) => { But it does not work. I tried stopPropagation as well. if there is a way to access event of form submission, I could have added a check to see if the textArea is in Focus and enter key is pressed then form won't be submitted. Would like to get a solution on this. |
it works now <TextArea {...field(model[fieldName] as unknown as AbstractModel)} className={'w-full'} label={'Message:'} required={true} style={{ width: '100%', minHeight: '200px', maxHeight: '250px' }} placeholder={'Write a message'} onValueChanged={handleTextAreaChange} onBlur={handleTextAreaBlur} onKeyDown={(event) => { event.stopPropagation(); }} ></TextArea>
|
Do not submit auto form on key-down if pressed in textarea Fixes #2697 Co-authored-by: Anton Platonov <platosha@gmail.com>
This ticket/PR has been released with Hilla 24.5.0.beta2 and is also targeting the upcoming stable 24.5.0 version. |
Describe the bug
When using a TextArea in an AutoForm like this
and the return key is pressed in the field, the form is submitted.
Expected-behavior
In a TextArea, the return key should only create a new line.
Reproduction
Can be observed in the examples at https://vaadin.com/docs/latest/components/auto-form#customizing-field-properties.
System Info
Vaadin 24.4.10
The text was updated successfully, but these errors were encountered: