Dropdown item onClick not firing when clicked
See original GitHub issueI’m passing down an array of items to a Dropdown component and for each I’m defining the value as a function. However, the onClick event doesn’t get called when I click the item. I found that if I made a small adjustment to line 105 of Dropdown Component it works:
Current implementation:
{ className: 'Dropdown-menu__action', onClick: self.onClick.bind(self, item.value) },
Working Implementation:
{ className: 'Dropdown-menu__action', onClick: item.value },
Thanks for this nice looking UI kit!
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
OnClick event not working in dropdown option - Stack Overflow
I have dropdown, When I choose option it will retrieve value from database and will shown on text feild. So I did Click...
Read more >The DropdownItem child do NOT get the click event #54 - GitHub
I updated the docs locally to wrap the text within the DropdownItem in a div with an onClick and it seems to be...
Read more >Button click is not working when dropdown value is selected
I am filling a drop down values using jquery and whenever i am selecting the values in that drop down, my server button...
Read more >React onClick event is not firing on bootstrap dropdown menu ...
You need e.preventDefault() in the click handler. It's firing but the default behavior of an anchor is to refresh the page, so it's...
Read more >onSelect event for react dropdown component
Thank you Anna,. But this does not change the MDBDropdownItem to the active class when clicked.
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 FreeTop 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
Top GitHub Comments
This definitely not a bug. So we can probably close this ticket.
But to resolve your issue @jonathanwmaddison, you have two problems:
onSelect
prop to alert the parent component that a value has been selected.value
s to direct your logic flowShould fix your problem.
@clschnei Thank you for the suggestions and for looking at my code so quickly. Hopefully this will help other coders with the same problem, and missed how to do this.