Avoiding nested forms #1049
Replies: 1 comment 2 replies
-
I see why you'd want to avoid this case, but not sure if just replacing the form with a div would be sufficient, as we rely on the submit and reset event autocomplete/packages/autocomplete-core/src/getPropGetters.ts Lines 120 to 145 in fdf2b34 I guess if those event listeners get added to a div they'll be useless, but that may not be an issue in your case if you manually trigger the submit. Do you have any ideas how to resolve that part? We obviously don't want to trigger submit or reset on the whole form. An alternative (less nice) solution is to place autocomplete outside the form DOM-wise and positioning it back inside using css, but that would be hard |
Beta Was this translation helpful? Give feedback.
-
Hello! We're using autocomplete.js as a tagging searchable autocompleting input of glory. The problem is that this occurs inside an existing form (as part of editing the object you are tagging). Nested forms technically work, but are disallowed by the HTML spec[1] and can cause weird submit behaviours.
We're open to making an MR allowing for the autocomplete.js form to produce div instead of a form [2], and effectively disabling the callbacks related to the HTMLFormElement, but wondering if this is something that the Algolia team is interested in, before we do the work.
I guess alternatives include forking the renderer and making the changes we need, or writing a custom renderer, but it seems likely others are facing this issue so this option might be welcome.
[1] https://dev.w3.org/html5/spec-LC/forms.html#the-form-element
[2]
autocomplete/packages/autocomplete-js/src/createAutocompleteDom.ts
Line 125 in b133e85
Beta Was this translation helpful? Give feedback.
All reactions