tbleckert / react-select-search

⚡️ Lightweight select component for React
https://react-select-search.com
MIT License
676 stars 149 forks source link

fix: render item elements as buttons, not submits #147

Closed yhnavein closed 3 years ago

yhnavein commented 3 years ago

By default options in the Select are rendered as button without an type attribute, which defaults to type="submit". Normally it's not a problem, because in most cases Search dropdown is rendered directly in the document body (outside of any forms), but if you choose to use render="always" then it starts to be a problem. Then list elements will behave as actual submit buttons. This is very bad.

I've added type="button" as this is a proper value in this case.

vercel[bot] commented 3 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/tbleckert/react-select-search/7n61f7i77
✅ Preview: https://react-select-search-git-fix-button-type.tbleckert.vercel.app

icaroscherma commented 3 years ago

Nice catch, I noticed this and came here to check if somebody has tackled this before me. =)

tbleckert commented 3 years ago

Nice! Great work @yhnavein . I'll merge this in and publish a patch later today. Let's put a hold on the optional chaining thing. I can imagine there's more places we could utilize it anyways, so we can pick up the conversation at a later stage.