-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
[Dialog] Modality changes #977
base: master
Are you sure you want to change the base?
Conversation
Netlify deploy preview |
9d83eb5
to
bb66879
Compare
16a17bb
to
9a01a54
Compare
const handleClick = React.useCallback( | ||
(event: React.MouseEvent) => { | ||
if (open) { | ||
setOpen(false, event.nativeEvent, 'click'); | ||
} | ||
}, | ||
[open, setOpen], | ||
); |
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.
useEventCallback
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.
Same here - setOpen
doesn't change between renders.
const handleFloatingUIOpenChange = React.useCallback( | ||
(isOpen: boolean, event: Event | undefined, reason: FloatingUIOpenChangeReason | undefined) => { | ||
setOpen(isOpen, event, translateOpenChangeReason(reason)); | ||
}, | ||
[setOpen], | ||
); |
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.
useEventCallback
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.
This depends on setOpen
only, which is stable.
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.
Yeah, but you need to specify the deps needlessly, plus for consistency it's good to wrap event handlers in it since it's used elsewhere
const handleFloatingUIOpenChange = React.useCallback( | ||
( | ||
nextOpen: boolean, | ||
event: Event | undefined, | ||
reason: FloatingUIOpenChangeReason | undefined, | ||
) => { | ||
setOpen(nextOpen, event, translateOpenChangeReason(reason)); | ||
}, | ||
[setOpen], | ||
); |
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.
Another here, though this one (and the one above) actually doesn't need to be wrapped, since it's done internally already
reason
parameter to Dialog'sonOpenChange
modal
prop valuepart of #623