Open samouss opened 5 years ago
Possible, it would avoid cases in which an InstantSearch component is wrapped inside a form. However, this should also be fine if we do preventDefault
inside each of the default event listeners. We can do that in a breaking change, but without breaking the DOM.
In which places do we have buttons?
Based on InstantSearch.js, we have buttons in:
searchBox
when searchAsYouType=false
voiceSearch
(to start searching by voice)infiniteHits
(to load previous or next hits)refinementList
(to load more facets)hierarchicalMenu
(to load more facets)menu
(to load more facets)currentRefinements
(to clear refinements)rangeInput
(to submit the range)clearRefinements
(to clear the refinements)relevantSort
(to toggle between all/relevant results)geoSearch
(to clear the map refinement)searchBox
and rangeInput
are the only ones where keeping a submit
button makes sense because they're wrapped with individual <form>
s and are meant to be submitted.
Others could use type="button"
, but I think the problem space might be bigger than that. If we wanted InstantSearch to work without JavaScript (SSR + route/form-based interactivity, like in Remix), we should have all buttons submit forms (either a big one around the whole experience, or individual ones).
For example, sortBy
could have a submit
button to apply the selected sorting option when JavaScript isn't enabled (and the refine
could happen server-side).
This requires a lot more research of course, and we can tackle issues separately, but in both cases, there will be breaking changes.