-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EnhancedButton] Fix onClick event being fired twice on "Enter Key" press #9439
[EnhancedButton] Fix onClick event being fired twice on "Enter Key" press #9439
Conversation
You need to select the |
Also, please update the commit message to match the revised PR title - it help keep the commit log clean, and simplifies preapring the release notes. Thanks! |
b35bfc1
to
6b1ffe9
Compare
@mbrookes thank you for the help. I renamed the commit message |
The pull request has been inactive for a month. I'm closing. Maybe someone will review it later. |
This is an odd bug. @karaggeorge, when I apply your changes within our app, I can see that the double-fire for the But, under normal circumstances without these changes, it is sometimes firing once, sometimes twice. Even using the same higher order component that calls the same underlying |
This breaks the tests no as the synthetic keyboard clicks no longer count.
I'm currently trying to find the actual root cause of the issue so this can be reverted and the tests run as planned. Personally I think it would be better to get to the root cause. |
It's essentially why I do no longer want to have to deal with v0.x. The test coverage is low. Every single change can lead to unexpected issues. I think that it's too much risk to accept significant pull-requests. I'm happy @djbuckley is looking into it. |
right .... I've been looking at this all day I think I can now see individual subpixels changing on my screen now .... 😵 The actual EnhancedButton was not malfunctioning at all. When the handleKeyUp fires the handleClick, a second event is generated that is trapped by the handleClick. I haven't been able to work out what is generating that second event 😕 so ... I have a patch that basically saves the timestamp of the last event processed by handleClick. If the current event being processed has the same timestamp then its ignored. ...thoughts?
|
@djbuckley I'm curious if you think this might actually make it into the the Material-UI v0.20 master branch at some point? I'm working on updating an app from v0.16.7 and this is definitely a stopper for me. Thanks for your work on it. |
Reinstated the keyUp handler. Added recording of the timestamp of events processed by handleClick to prevent processing of duplicated events. mui#9439 mui#9344 Background : The handleKeyUp firing of handleClick is duplicating the event on the processing queue. I've not been able to find the reason for the duplication, I suspect something lower down in the React stack... but I can't prove it either way. This will however stop a duplicated click event being processed more than once.
@caseychoiniere I've put the change in as a pull request, so .... theoretically it should come through. If anyone finds a better way to keep the functionality originally there without this mitigation... please write it up |
* commit 'fbfd478b85d02c1fc61ce525bee832f960792bfa': Use selectionEnd instead of selectionEnd to fix caret position issue (mui#10214) Static properties for reason string constants (mui#10300) conditionally apply overlay bkg (mui#9811) fix: handle case where ref is null (mui#10006) [EnhancedButton] Fix onClick event being fired twice on "Enter Key" press (mui#9439) The Popover does not listen to events unless it is open at the moment (mui#9482) [docs] Add v1 recommendation to home page (mui#9727) [Tabs] Add support for inline style override for parent container of InkBar (mui#9598) # Conflicts: # src/Popover/Popover.js # src/Slider/Slider.js # src/Snackbar/Snackbar.js
This PR solves this issue: #9344
This is my first PR to this repo, so I'm not quite familiar with the process. The bug doesn't exist on v1x. Only for v0.20.0. I created my branch from that, but I can only create this PR against master or v1-beta.
The issue was that the event was fired once from the normal
onClick
proc which happens naturally when space/enter is pressed on a focused button, and then once more from thekeyDown
andkeyUp
events in theEnhancedButton
component manually. That's why the problem showed up in all the buttons. Removing those extra checks and event fires solved the issue.I wasn't able to write a failing test for the bug, since Enzyme event simulations call the handlers directly and don't actually simulate browser events.