algolia / instantsearch

⚡️ Libraries for building performant and instant search and recommend experiences with Algolia. Compatible with JavaScript, TypeScript, React and Vue.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/
MIT License
3.71k stars 520 forks source link

Button should have a default type to "button" ? #5190

Open samouss opened 5 years ago

samouss commented 5 years ago

https://github.com/algolia/instantsearch.js/issues/5264

Haroenv commented 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?

sarahdayan commented 1 year ago

Based on InstantSearch.js, we have buttons in:

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.