Skip to content
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

EuiSelect: prevent propagation on inconsistent mouseup events #1926

Merged
merged 7 commits into from
May 8, 2019

Conversation

thompsongl
Copy link
Contributor

@thompsongl thompsongl commented May 7, 2019

Summary

Fixes #1881, in which inconsistent browser implementations of mouse events on select elements would cause/prevent unintended state updates.

The egregious example is Firefox, which emits mouseup events only on select option interaction. The propagated event would result in a setState race condition when used with EuiOutsideClickDetector (EuiOutsideClickDetector must use mouse events rather than click events due to other browser inconsistencies).

Proposal

The solution this PR proposes is to normalize all browsers to the "lowest" common event result: Safari, which does not emit any mouseup events for select element interaction. The result of this is consistent eventing across supported browsers, but prevents clicks on EuiSelect from triggering EuiOutsideClickDetector behavior (Note, this happens in Safari regardless of this PR). I will document this in the example should we continue with this pattern.

Alternative

To alleviate the Firefox-specific issue, we could stop propagation of only mouseup events on select option interaction. This would lead to different EuiOutsideClickDetector outcomes in each of our supported browsers, however.

Browser Reference

Browser select mousedown select mouseup option mousedown option mouseup
Chrome ✔️ ✔️*
Firefox ✔️ ✔️ ✔️
Safari ✔️
Edge ✔️ ✔️
IE11 ✔️ ✔️ ✔️ ✔️

* Occurs even if mouse remains down

Checklist

- [ ] This was checked in mobile

  • This was checked in IE11

- [ ] This was checked in dark mode
- [ ] Any props added have proper autodocs
- [ ] Documentation examples were added

  • A changelog entry exists and is marked appropriately

  • This was checked for breaking changes and labeled appropriately

- [ ] Jest tests were updated or added to match the most common scenarios
- [ ] This was checked against keyboard-only and screenreader scenarios
- [ ] This required updates to Framer X components

@chandlerprall
Copy link
Contributor

The result of this is consistent eventing across supported browsers

Yay!

but prevents clicks on EuiSelect from triggering EuiOutsideClickDetector behavior

ugh!

Note, this happens in Safari regardless of this PR

blargh!

I agree with the proposed solution, bringing everything in alignment with Safari's defaults. If selects not triggering outside click detection becomes a noticeable problem we can solve separately by making those components aware of each other, but as stated it's already been broken in Safari.

@thompsongl
Copy link
Contributor Author

Added documentation. Will add CL entry after release churn ends.

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM

@thompsongl thompsongl merged commit debab6b into elastic:master May 8, 2019
@thompsongl thompsongl deleted the 1881-select-outside-click branch May 8, 2019 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EuiOutsideClickDetector fires early on overrides value in firefox
2 participants