-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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] Fix children
and onClickAway
types
#24565
Conversation
36490d9
to
6f10c71
Compare
if ( | ||
!activatedRef.current || | ||
!nodeRef.current || | ||
('clientX' in event && clickedRootScrollbar(event, doc)) |
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.
We used to access event.clientX
on touch events which don't implement that property. So we would always end up evaluating doc.documentElement.clientWidth < undefined || doc.documentElement.clientHeight < undefined
. This always evaluates to false
so we can bail out early by checking if we have a MouseEvent.
In the end we're forcing less layout on touch events (no access to element.clientWidth
) but check property existence more often. Seems like a good tradeoff considering forcing layout is much more expensive than checking property existence and touch events are usually dispatched on weaker devices e.g. smartphones.
e0b93ad
to
2980efa
Compare
2980efa
to
569dcf4
Compare
* next: (34 commits) [Tab] Migrate to emotion (mui#24651) [TextField] Migrate Input component to emotion (mui#24638) [ImageList] Migrate ImageListItemBar to emotion (mui#24632) [CircularProgress] Migrate to emotion (mui#24622) [DataTable] Add example in docs for data table (mui#24428) [Card] Migrate CardActionArea to emotion (mui#24636) [core] Fix `next` using stale pages (mui#24635) [List] Migrate ListItemIcon to emotion (mui#24630) [ClickAwayListener] Fix `children` and `onClickAway` types (mui#24565) [docs] Include in docs directive to silence `eslint` erroneous warning (mui#24644) [Fab] Migrate to emotion (mui#24618) [TextField] Migrate FilledInput to emotion (mui#24634) [Card] Migrate CardHeader to emotion (mui#24626) [Card] Migrate CardMedia to emotion (mui#24625) [ImageList] Migrate ImageListItem to emotion (mui#24619) [website] Add vision block (mui#24603) [docs] Add sorting section (mui#24637) [TextField] Prepare removal of labelWidth prop (mui#24595) [Dialog] Migrate DialogTitle to emotion (mui#24623) [ImageList] Migrate to emotion (mui#24615) ...
Based on #24564 (diff)
children
allowed a nullableReactNode
when we actually treat it as a non-nullableReactElement
.onClickAway
would allow treating the event as a React event when we only pass it a native event.Test plan