Skip to content

Conversation

@TylerJDev
Copy link
Member

@TylerJDev TylerJDev commented Nov 5, 2025

Closes https://github.com/github/primer/issues/6003.

Video example

Screen.Recording.2025-11-06.at.8.32.08.AM.mov

Hides tooltip based on ARIA props passed to IconButton. This solution mainly targets ActionMenu usage with IconButton, but may be applicable elsewhere.

Changelog

New

  • Tooltip is now hidden when a menu is open.

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@changeset-bot
Copy link

changeset-bot bot commented Nov 5, 2025

🦋 Changeset detected

Latest commit: eb209fe

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

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

@github-actions github-actions bot added staff Author is a staff member integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Nov 5, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

@github-actions github-actions bot temporarily deployed to storybook-preview-7142 November 5, 2025 21:47 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-7142 November 6, 2025 03:15 Inactive
@TylerJDev TylerJDev changed the title Tooltip: Hide Tooltip when menu is active TooltipV2: Hide Tooltip when menu is active Nov 6, 2025
@TylerJDev TylerJDev marked this pull request as ready for review November 6, 2025 13:36
@TylerJDev TylerJDev requested a review from a team as a code owner November 6, 2025 13:36
@TylerJDev TylerJDev requested review from Copilot and pksjce November 6, 2025 13:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where TooltipV2 was displayed even when an ActionMenu was open. The solution involves detecting when an IconButton has an active popup (specifically a menu) and suppressing the tooltip in that state.

Key changes:

  • IconButton now checks for active popup state (expanded + has menu popup) to conditionally hide tooltips
  • AnchoredOverlay accepts an aria-haspopup prop to allow customization of the ARIA attribute
  • ActionMenu explicitly sets aria-haspopup="menu" on its overlay

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/react/src/Button/IconButton.tsx Adds logic to hide tooltip when button has an active menu popup by checking aria-expanded and aria-haspopup props
packages/react/src/AnchoredOverlay/AnchoredOverlay.tsx Adds aria-haspopup prop to allow consumers to specify the type of popup, defaulting to 'true'
packages/react/src/ActionMenu/ActionMenu.tsx Passes aria-haspopup="menu" to AnchoredOverlay to indicate menu popup type
.changeset/wild-aliens-itch.md Documents the change as a minor version update

@github-actions github-actions bot requested a deployment to storybook-preview-7142 November 6, 2025 13:45 Abandoned
@github-actions github-actions bot added integration-tests: failing Changes in this PR cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Nov 6, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-7142 November 6, 2025 13:54 Inactive
@TylerJDev TylerJDev force-pushed the tylerjdev/hide-tooltip-for-menu branch from 357076e to 9e892b4 Compare November 7, 2025 13:46
@github-actions github-actions bot requested a deployment to storybook-preview-7142 November 7, 2025 13:55 Abandoned
@primer-integration
Copy link

😢 Hi from github/github-ui. The integration workflow has failed: https://github.com/github/github-ui/actions/runs/19170653419

@primer-integration
Copy link

🟢 ci completed with status success.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

👋 Hi, there are new commits since the last successful integration test. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the integration-tests: skipped manually label to skip these checks.

@github-actions github-actions bot added integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Nov 7, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

👋 Hi, there are new commits since the last successful integration test. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the integration-tests: skipped manually label to skip these checks.

@github-actions github-actions bot added integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Nov 7, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

👋 Hi, there are new commits since the last successful integration test. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the integration-tests: skipped manually label to skip these checks.

@github-actions github-actions bot removed the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Nov 7, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

👋 Hi, there are new commits since the last successful integration test. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the integration-tests: skipped manually label to skip these checks.

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Nov 7, 2025
@github-actions github-actions bot temporarily deployed to storybook-preview-7142 November 7, 2025 17:27 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-7142 November 7, 2025 17:37 Inactive
Copy link
Member

@joshblack joshblack left a comment

Choose a reason for hiding this comment

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

Random, since we already are attaching event listeners to the child could we attach something like onClick that will trigger hiding the tooltip? Or is that too broad of an event?

It seems like we want cases where button:active is true to dismiss the tooltip if I'm understanding right, let me know if not 👀

*
* @default false
*/
closeTooltip?: boolean
Copy link
Member

@siddharthkp siddharthkp Nov 7, 2025

Choose a reason for hiding this comment

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

Can we make this an internal mechanism instead of part of the API? Don't want to accidentally introduce/promote a way of disabling tooltips unless that is the explicit intention.

If it exists, it will get used; we still have 57 instances of unsafeDisableTooltip that have not been cleaned up 😅

Possible solutions:

  1. Using TooltipContext that IconButton is already aware of
  2. Using css to hide the tooltip, would something like :has(button[aria-expanded=true]) work?
  3. _privateDisableTooltip prop that looks private and we don't document (we have a similar prop in ActionList)

Copy link
Member Author

Choose a reason for hiding this comment

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

Definitely can! I'm thinking option 3 might be the best, but let me know what you think.

Using TooltipContext that IconButton is already aware of

This could work, we are exposed to TooltipContext, which currently provides the ID. We're mostly relying on what ActionMenu (through AnchoredOverlay) provides to IconButton to determine if it should be hidden or not (if aria-expanded="true" and aria-haspopup="true" exist on the IconButton)

I'm not too sure what we could pass to context for Tooltip here 🤔 We could check within Tooltip for if it's a menu, but that might add more logic to handle. Let me know what you think though 👀

Using css to hide the tooltip, would something like :has(button[aria-expanded=true]) work?

This would definitely work! The only concern is how we'd scope it to only apply if it's both an IconButton and that button triggers a menu.

e.g. :has(button[aria-expanded=true][aria-haspopup=true])

<!-- We'd only want the CSS to apply to the second button (IconButton) -->
<button aria-haspopup="true" aria-expanded="true">Not an IconButton</button>
<button className="IconButton" aria-haspopup="true" aria-expanded="true">Is an IconButton</button>

There doesn't' seem to be a good identifier between the buttons 🤔

_privateDisableTooltip prop that we don't document (we have a similar prop in ActionList)

This works! Ideally we wouldn't have to use a prop to begin with, but I figured that this approach is less likely to interfere with any existing Tooltip or IconButton instances.

Copy link
Member

Choose a reason for hiding this comment

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

There doesn't' seem to be a good identifier between the buttons 🤔

data-component="IconButton"?

I'm not too sure what we could pass to context for Tooltip here 🤔 We could check within Tooltip for if it's a menu, but that might add more logic to handle. Let me know what you think though 👀

The provider is in the tooltip which wraps the button, so would have to pass a function down in context for button to call. Not my favorite.

Definitely can! I'm thinking option 3 might be the best

Good backup if the css other does not work reliably

@TylerJDev
Copy link
Member Author

Random, since we already are attaching event listeners to the child could we attach something like onClick that will trigger hiding the tooltip? Or is that too broad of an event?

It seems like we want cases where button:active is true to dismiss the tooltip if I'm understanding right, let me know if not 👀

Just to confirm, is the child in this case the one within Tooltip (via Tooltip.tsx#L269)? Does this mean instead of applying the logic through IconButton, apply it within Tooltip through an event that checks if button:active?

@github-actions github-actions bot removed the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Nov 7, 2025
@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Nov 7, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

👋 Hi, there are new commits since the last successful integration test. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the integration-tests: skipped manually label to skip these checks.

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

Labels

integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants