Skip to content

fix: hide unmeasured tooltips during exit - #10502

Open
devo-id wants to merge 3 commits into
adobe:mainfrom
devo-id:fix/tooltip-unmeasured-exit
Open

fix: hide unmeasured tooltips during exit#10502
devo-id wants to merge 3 commits into
adobe:mainfrom
devo-id:fix/tooltip-unmeasured-exit

Conversation

@devo-id

@devo-id devo-id commented Aug 24, 2026

Copy link
Copy Markdown

Closes #10496

When a Tooltip starts its exit animation before its position has been calculated, it can remain mounted with the fallback position: fixed; top: 0; left: 0 styles and briefly appear at the top-left of the viewport.

This change hides the tooltip when it is closed and does not have a computed placement:

visibility: !placement && !state.isOpen ? 'hidden' : undefined

Normally positioned tooltips and their exit animations are unchanged.

Pull Request Checklist:

Test Instructions:

  1. Run:
    yarn jest packages/react-aria-components/test/Tooltip.test.js

  2. The regression test hides unmeasured tooltips during exit animation should fail on upstream/main and pass with this change.

  3. Also verified:

    • yarn jest packages/react-aria-components/test/Toolbar.test.tsx
    • yarn jest packages/react-aria/test/overlays/useOverlayPosition.test.tsx
    • yarn jest packages/react-aria-components/test/Popover.test.js
    • yarn oxlint packages/react-aria-components/src/Tooltip.tsx packages/react-aria-components/test/Tooltip.test.js
    • yarn oxfmt --check packages/react-aria-components/src/Tooltip.tsx packages/react-aria-components/test/Tooltip.test.js

@devo-id

devo-id commented Aug 24, 2026

Copy link
Copy Markdown
Author

I investigated the failing s2-docs check locally by running the same build on both my PR branch and upstream/main. Both fail at packages/dev/s2-docs/pages/s2/dnd.mdx:41 because ./DroppableCOMPONENT cannot be resolved. So this appears to be an existing upstream docs build issue, unrelated to this PR.

expect(button).toHaveAttribute('tabindex', '0');
});

it('hides unmeasured tooltips during exit animation', () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is pretty specific to the implementation, probably better to reproduce the actual user flow in the test with mocked timers if possible

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I agree the test should cover the actual focus flow rather than asserting the visibility style directly. I'll hold off on changing the test until we settle on the implementation approach.

);

let tooltip = getByRole('tooltip', {hidden: true});
expect(tooltip).toHaveStyle('visibility: hidden');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we do the either of the suggestions I had instead, we could instead listen to onOpenChange in TooltipTrigger and assert it was never called

style={
{
...overlayProps.style,
visibility: !placement && !state.isOpen ? 'hidden' : undefined,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely an interesting approach

some other approaches I'd had:

  • delay opening a tooltip on focus until setTimeout(0) and check that focus is still there
  • fire a custom event that tells a TooltipTrigger that focus will just be passing through, don't bother opening a tooltip

I'm not yet sure which approach I like best, so it's a question for the team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Combination of Toolbar and Tooltip causes glitching on Tooltip

2 participants