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

[ClickAwayListener] Don't call onClickAway in the event cycle that mounted it #25741

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Apr 12, 2021

May break existing tests. For review please only look at <ClickAwayListener /> tests and implementation. Review per commit is also advised.

With event cycle we refer to the order of events that is dispatched during a user mouse press.

Previously onClickAway could be called during the same user mouse press that mounted the component. All of the know cases turned out to be undesired so indead of fixing each symptom individually we just completely ignore the user mouse press that mounted the listener.

Note that this isn't targetted at #25578 which has the CAL permanently mounted. We can only change #25578 if we check for click-away in mouseup only (essentially removing the mouseEvent prop.

The required changes to tests are unfortunate. People using user-event should have no breakage. Upside is that we force people (app devs) to write their tests closer to what happens in a browser. For libraries built on top of Material-UI the story might look different but that's not really a usage we support anyway.

Alternate to #25630

@eps1lon eps1lon added the component: ClickAwayListener The React component label Apr 12, 2021
@mui-pr-bot
Copy link

mui-pr-bot commented Apr 12, 2021

Details of bundle changes

Generated by 🚫 dangerJS against a963ffc

@eps1lon eps1lon force-pushed the feat/clickawaylistener/activate-next-event-cycle branch from 37423df to dc41b01 Compare April 13, 2021 10:37
@eps1lon eps1lon marked this pull request as ready for review April 13, 2021 11:03
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

This alternative fix to #23315 looks OK. It seems interesting that we do no longer rely on a setTimeout, it might make it easier for developers to test on their side.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 25, 2021
@oliviertassinari oliviertassinari deleted the branch mui:next June 22, 2021 00:28
@oliviertassinari oliviertassinari changed the base branch from foo to next June 22, 2021 00:48
@eps1lon
Copy link
Member Author

eps1lon commented Sep 6, 2021

It's just fixing a well-specified behavior depending on internals. This is not teachable.

@eps1lon eps1lon closed this Sep 6, 2021
@eps1lon eps1lon deleted the feat/clickawaylistener/activate-next-event-cycle branch September 6, 2021 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: ClickAwayListener The React component PR: out-of-date The pull request has merge conflicts and can't be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants