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.

[Select] onClick not fired on menu items

See original GitHub issue
  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

If you select the same value twice in a single Select, onChange is not called the second time.

Expected Behavior 🤔

onChange should be called every time a user selects a value, even if it’s the same value as before.

Steps to Reproduce 🕹

Here’s an example of functionality that worked in v4.9.8: https://codesandbox.io/s/frosty-cohen-gpk3y?file=/src/Demo.js

Here’s the same code not working in v4.9.9: https://codesandbox.io/s/hungry-neumann-y0ht0?file=/src/Demo.js

Steps:

  1. Click on the Select
  2. Select the value that is already selected

Context 🔦

We prefer to have the single Select behave in the same way as the multi Select- click on an already selected item to deselect it. Without an event, we can’t do that.

Related issue: https://github.com/mui-org/material-ui/issues/20351 Related PR: https://github.com/mui-org/material-ui/pull/20361

Your Environment 🌎

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
oliviertassinaricommented, Apr 24, 2020

<kbd>Enter</kbd> will trigger onClick, we are good.

0reactions
tpeekcommented, Apr 24, 2020

I think we might have to do a bit more with the onKeyUp part- I’ve tested passing onKeyUp to each MenuItem, and it works for the arrow keys but not for the ‘Enter’ key. Example: https://codesandbox.io/s/divine-violet-jucyq?file=/src/Demo.js

My guess is that the Menu closes onKeyDown, so the MenuItem isn’t around for the onKeyUp event.

Read more comments on GitHub >

github_iconTop Results From Across the Web

onclick not working for select menu options
I'm a beginner at HTML, and I have a problem with the onclick and the select (dropdown list). I know I did something...
Read more >
mui/material-ui - [Select] onClick not fired on menu items
The issue is present in the latest release. I have searched the issues of this repository and believe that this is not a...
Read more >
onclick handler is not fired correctly when it is in OPTION ...
Issue 5284: onclick handler is not fired correctly when it is in OPTION ... the "onclick" event is triggered in Chrome/Safari, the value...
Read more >
Select not working - options not appearing on click
Hi, I am having trouble with the material select in my application. The element looks as if it is initializing as expected, however...
Read more >
Element: click event - Web APIs | MDN
Add a dummy onclick="void(0)" attribute to the element or any of its ancestors up to but not including <body> . Use a typically...
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