-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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(bubble-menu): add focusout handler for floating element #5882
base: develop
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 32c4b2b The changes in this PR will be included in the next version bump. This PR includes changesets to release 54 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 |
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Looks good to me - would like to change the changeset a bit to be more clear about what changed.
@@ -50,7 +50,7 @@ export const BubbleMenu = (props: BubbleMenuProps) => { | |||
}, [props.editor, currentEditor, element]) | |||
|
|||
return ( | |||
<div ref={setElement} className={props.className} style={{ visibility: 'hidden' }}> | |||
<div ref={setElement} tabIndex={-1} className={props.className} style={{ visibility: 'hidden' }}> |
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.
Did you test if a negative tab index still allows the client to focus elements inside the div via the keyboard?
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.
Yes, you can still focus on other elements inside using tab
This is necessary so that event.relatedTarget
is not null
if an empty space was clicked inside the bubble-menu
Co-authored-by: bdbch <[email protected]>
Changes Overview
Fix the bug where the bubble menu does not hide
Implementation Approach
Add an additional focusout event handler to the floating element.
Also, set tabIndex to -1 for the bubble menu to ensure that clicking on an empty block in the bubble menu does not result in the parentNode being null.
Testing Done
Test on a local
Verification Steps
Add input into bubble-menu demo
Open BubbleMenu
Click on the input
Click outside the editor
Additional Notes
Checklist
Related Issues
#578