Add documentation about getButtonProps applying type: 'button' by default
See original GitHub issuedownshift
version: 2.0.10node
version: 9.11.1npm
(oryarn
) version: 1.7.0
Relevant code or config N/A
Problem description: I was trying to toggle Downshift when submitting a form by pressing Enter in an input, thinking that the form would submit (normal behaviour), but it didn’t. Looking at #315 I saw why and “fixed” it (because the current behaviour makes more sense). However, maybe we should document it?
Suggested solution: We could add a simple note such as below:
Note that
getButtonProps
appliestype: 'button'
by default, so make sure to passtype: 'submit'
to this control prop if you want to have the normal behaviour of a button inside a form.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
The Button element - HTML: HyperText Markup Language
The default behavior of the button. Possible values are: submit : The button submits the form data to the server.
Read more >Buttons - Bootstrap
Use Bootstrap's custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.
Read more >useDisclosure - Chakra UI
useDisclosure. useDisclosure is a custom hook used to help handle common open , close , or toggle scenarios. It can be used to...
Read more >SearchBox | Elastic docs
Note: Elastic App Search currently only supports type "documents", and Elastic Site Search and Workplace Search do not support suggestions.
Read more >What is the default button type? - html - Stack Overflow
For most browsers the default type of button is submit . type = submit|button|reset [CI]. This attribute declares the type of the button....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I totally missed that
openMenu
prop, thanks for pointing it out, @stipsan.By using that, I can accomplish the same behavior with a more correct code and without
getButtonProps
as @kentcdodds said.Thank you both!
Thanks for sharing the example, it makes it more clear what you mean 😄
Have you considered customizing the submit event that is currently calling
e.preventDefault()
and use theopenMenu
prop in there to open downshift? In my experience relying on how browsers deal with onClick on submit buttons when hitting enter on text inputs can be really flaky between browsers. It can also make the code harder to maintain since the logic flow rely on behaviors that are implicit 😅