Skip to content

fix(Tooltip): make tooltips with empty text inert - #8740

Merged
tay1orjones merged 4 commits into
mainfrom
tay1orjones-tooltip-disabled-prop
Nov 19, 2026
Merged

tay1orjones merged 4 commits into
mainfrom
tay1orjones-tooltip-disabled-prop

Conversation

@tay1orjones

Copy link
Copy Markdown
Contributor

Closes #8571

Keeping a Tooltip mounted while toggling its text avoids replacing the trigger and dropping focus. Empty text without a keybinding hint now makes Tooltip inert and removes its ARIA association.

Changelog

New

Changed

  • An empty text no longer opens a Tooltip or labels/describes its trigger when no keybindingHint is provided.

Removed

Rollout strategy

  • No changes needed in github/github-ui
  • Needs changes in github/github-ui
  • Ships with feature flag(s)
  • Not sure
  • None

Testing & Reviewing

Automated coverage exercises focus retention, tooltip open/close behavior, and ARIA attributes; type-check and targeted lint pass. In the ConditionalText story, toggle the tooltip and confirm focus stays on the button and its accessible description disappears while the text is empty.

A tooltip with empty `text` (and no `keybindingHint`) no longer opens and
no longer labels or describes its trigger. That means you can turn a tooltip
off with `text={allowed ? '' : 'Not allowed'}` instead of conditionally
wrapping the trigger, which remounts it and drops focus.

Fixes #8571

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7370f21

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 Patch

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 the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

@github-actions
github-actions Bot temporarily deployed to storybook-preview-8740 November 12, 2026 15:01 Inactive
@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 12, 2026
The empty-text effect cancelled the pending hover timer. If the text came back while the pointer was already over the trigger, no new mouseover fired, so the tooltip never opened.

The effect now only hides an open popover. The hover timer reads the latest props when it fires: it opens if content has returned and does nothing if the text is still empty.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions
github-actions Bot temporarily deployed to storybook-preview-8740 November 13, 2026 22:17 Inactive
@github-actions github-actions Bot added integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: failing Changes in this PR cause breaking changes in gh/gh labels Nov 16, 2026
@primer primer deleted a comment from primer-integration Bot Nov 16, 2026
@github-actions github-actions Bot added integration-tests: failing Changes in this PR cause breaking changes in gh/gh integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh integration-tests: failing Changes in this PR cause breaking changes in gh/gh labels Nov 16, 2026
@tay1orjones
tay1orjones marked this pull request as ready for review November 16, 2026 21:27
@tay1orjones
tay1orjones requested a review from a team as a code owner November 16, 2026 21:27
@tay1orjones
tay1orjones requested review from llastflowers and a balanced review from Copilot November 16, 2026 21:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the changes supporting empty tooltip text while preserving trigger focus.

No open issues 🎉

What changed in this PR

This PR addresses #8571 by using empty Tooltip text to disable tooltip behavior without remounting the trigger, preserving keyboard focus.

Changes:

  • Adds content checks for opening, closing, and associating tooltips with their triggers.
  • Adds tests for empty text, focus retention, ARIA attributes, and pending hover behavior.
  • Documents conditional text usage, adds a Storybook example, and includes a patch changeset.
File Description
packages/​react/​src/​TooltipV2/​Tooltip.tsx Adds content-dependent visibility and ARIA handling.
packages/​react/​src/​TooltipV2/​Tooltip.features.stories.tsx Adds a conditional-text example.
packages/​react/​src/​TooltipV2/​Tooltip.docs.json Documents empty-text behavior and registers the example.
packages/​react/​src/​TooltipV2/​__tests__/​Tooltip.test.tsx Covers empty-text behavior and focus preservation.
.changeset/​tooltip-empty-text.md Adds an @primer/react patch release note.

Review effort: Balanced

@primer-integration

Copy link
Copy Markdown

Integration test results from github/github-ui PR:

Passed  Changes   Passed
Passed  CI   Passed
Passed  VRT   Passed
Passed  Projects   Passed

All checks passed!

…isabled-prop

# Conflicts:
#	packages/react/src/TooltipV2/__tests__/Tooltip.test.tsx
@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 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 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. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

Ultroncn

This comment was marked as resolved.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 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. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

@tay1orjones
tay1orjones added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit f0918eb Nov 19, 2026
62 checks passed
@tay1orjones
tay1orjones deleted the tay1orjones-tooltip-disabled-prop branch November 19, 2026 20:57
@primer primer Bot mentioned this pull request Nov 19, 2026

This branch was successfully deployed

1 active and 1 inactive deployments
storybook-preview-8740 — 7370f213 Deployed Nov 19, 2026 by github-actions[bot]
github-pages — 7370f213 Deployed Nov 19, 2026 by tay1orjones via deploy-preview #34447
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 integration-tests: skipped manually Changes in this PR do not require an integration test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conditional tooltips make the trigger lose focus

4 participants