-
Notifications
You must be signed in to change notification settings - Fork 80
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
fix(menu): Safari issue on closing menu clicking on trigger #2338
Conversation
🦋 Changeset detectedLatest commit: ff399fb The changes in this PR will be included in the next version bump. This PR includes changesets to release 33 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
Can you explain your considerations around the Downshift approach a bit more? Looking at the code I think I understand it better to be honest. |
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.
Nice, I like the approach you chose 👍
I would just add more explanation around the issue in the code.
@@ -150,12 +150,26 @@ export function Menu(props: MenuProps) { | |||
[closeAndFocusTrigger, handleArrowsKeyDown], | |||
); | |||
|
|||
const isMouseDown = useRef<Boolean>(false); |
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.
const isMouseDown = useRef<Boolean>(false); | |
// the comment that explains the issue in safari that we are trying to fix here. Because the one we have in the `onMouseDown` event is not clear enough for me. | |
const isTriggerMouseDown = useRef<Boolean>(false); |
WDYT?
// handle odd case for Safari which | ||
// prevent triggering blur when MouseDown | ||
isMouseDown.current = true; | ||
_props.onMouseDown?.(event); | ||
}, | ||
onMouseUp: (event) => { | ||
// handle odd case for Safari | ||
// set isMouseDown as false to enable blur |
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.
and then this comments we can delete I guess
Sorry, had a typo there, I fixed it. |
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.
and I just remembered that we need to do the same for the Popover
Purpose of PR
Fix issue with Safari when trying to close menu by clicking on the trigger
Obs:
tabindex=0
inside the button and use it to trigger the events, which in our case would be tricky since the trigger could be a button or not.MouseDown
, so trying to set the focus on theonClick
wasn't working. Which would means that we would have to manually focus on the events.