prevent Enter key from submitting form during autocomplete selection (#7221)

This commit is contained in:
Ayush
2026-03-27 20:04:52 +05:30
committed by GitHub
parent f1b84e09c3
commit d07c323755

View File

@@ -317,9 +317,15 @@ const NewRequest = ({ collectionUid, item, isEphemeral, onClose }) => {
className="bruno-form"
onSubmit={formik.handleSubmit}
onKeyDown={(e) => {
if (e.key === 'Enter') {
e.preventDefault();
formik.handleSubmit();
if (e.key === 'Enter' && !e.defaultPrevented) {
const isTextInput
= ['input', 'textarea'].includes(e.target.tagName.toLowerCase())
|| e.target.isContentEditable;
if (!isTextInput) {
e.preventDefault();
formik.handleSubmit();
}
}
}}
>