-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Site Settings: Add stopPropagation to SELECT onClick events #1228
Conversation
onClick was propagating to label, triggering click events higher in DOM tree in Safari. Fixes #86
@@ -62,6 +62,11 @@ module.exports = { | |||
|
|||
}, | |||
|
|||
recordClickEventAndStop: function( recordObject, clickEvent ) { | |||
this.recordEvent( recordObject ); | |||
clickEvent.preventDefault(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@artpi I think the intent here is to stop the click event from bubbling up to the label as you noted so we only need stopPropagation
. Using preventDefault
here might mislead some one into thinking we want to prevent the default action of the select
element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@omarjackman : TLDR: stopPropagation
doesent work.
I have tried that before, but I dont know what happens on Safari that even when I stop propagation, it still goes up the DOM tree.
This is the only solution that works. Maybe some problem with React synthetic events...
@artpi I've confirmed that You're good to 🚢 once that's done. |
@artpi I ran into a similar issue and found this answer on StackOverflow which makes sense of whats going on here. Cant stop propagation because it has already propagated by the time your handler is invoked. Just stating the obvious that |
…i-toggle Site Settings: Add stopPropagation to SELECT onClick events
What?
While nested in
LABEL
,SELECT
onClick
event was propagatingonClick was propagating to label, triggering click events higher
in DOM tree in Safari. Fixes #86
Problem
(Copied from #86 )
My Sites > Settings > Discussion
Click on a select element, and it toggles the checkbox. Looks like it only affects Safari, not Chrome or Firefox. IE untested.
Testing