question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add documentation about getButtonProps applying type: 'button' by default

See original GitHub issue
  • downshift version: 2.0.10
  • node version: 9.11.1
  • npm (or yarn) 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 applies type: 'button' by default, so make sure to pass type: 'submit' to this control prop if you want to have the normal behaviour of a button inside a form.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
arthurdennercommented, Jul 11, 2018

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!

0reactions
stipsancommented, Jul 11, 2018

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 the openMenu 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 😅

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found