-
Notifications
You must be signed in to change notification settings - Fork 700
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
[Tooltip] Tooltip is opened on active buttons when the browser tab is switched #1800
Comments
Reproducing and experiencing the same issue. |
are you getting a memory leak warning for this? |
There are some other similar cases where this experience happens. From looking at the code, it's anytime the trigger regains focus but the pointer is not down. Another example case would be closing a dialog or other modal experience with the escape button. This returns focus to the trigger, but the pointer is not pressed. Alternatively, a click event only fires after the pointer up, so any button click in a dialog that closes the dialog and returns the focus will likely have this same issue. |
Nope |
Seems a different issue to me. The one I've reported is caused by the browsers behavior of triggering a focus event when the tab/window goes back to the active state. |
We've experienced this behaviour as well. We commonly have Icon Buttons with Tooltips that activate Dialogs. Once the Dialog is closed, the Tooltip is shown because focus is returned back to the Icon Button. It strikes me that this is not ideal behaviour. It's a bit confusing and annoying as a user, but I will also admit I'm not intimately familiar with all the accessibility guidelines for Tooltips. Perhaps this is intended behaviour? If it's not intended behaviour it would be useful to get a fix for it because I expect it's not uncommon to use these components together so it seems like a common issue users will run into. As I currently understand it, it seems plausible that the issues @gdorsi and @sfrieson have described are the same root cause. What if there was an extra check added here that checked if the target of the tooltip has onFocus={composeEventHandlers(props.onFocus, (event) => {
if (!isPointerDownRef.current && document.querySelector("*:focus-visible") === event.currentTarget) context.onOpen();
})} |
Bug report
Current Behavior
Steps:
This happens also when the browser window is minimized/maximized.
Expected behavior
The tooltip shouldn't be open when the tab becomes active again
Reproducible example
https://www.radix-ui.com/docs/primitives/components/tooltip
Suggested solution
The issue is triggered by the onFocus handler because the browser triggers a focus event when the page becomes visible.
I've applied this workaround on my tooltips:
To make the example small I've placed everything in the component, but it's better to track the previous active element inside a provider.
I'm migrating from tippy.js and while they handle focus they don't have the same issue.
I would also check there to find a possible solution.
Your environment
The text was updated successfully, but these errors were encountered: