Skip to content

[tooltip] Prevent opening when focusing a disabled Trigger - #3902

Merged
michaldudak merged 1 commit into
mui:masterfrom
michaldudak:fix-tooltip-disabled-focus
Feb 9, 2026
Merged

michaldudak merged 1 commit into
mui:masterfrom
michaldudak:fix-tooltip-disabled-focus

Conversation

@michaldudak

@michaldudak michaldudak commented Jan 30, 2026 •

Copy link
Copy Markdown
Member

When the disabled prop is set on the Trigger, it's still possible to open the tooltip by focusing the trigger. This PR fixes it, making it consistent with the behavior on hover.

Fixes #3468

@michaldudak
michaldudak requested a review from atomiks as a code owner January 30, 2026 12:05
@michaldudak michaldudak added the type: bug It doesn't behave as expected. label Jan 30, 2026
@michaldudak michaldudak added the component: tooltip Changes related to the tooltip component. label Jan 30, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jan 30, 2026

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@3902
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@3902
    

commit: 83f6263

@mui-bot

mui-bot commented Jan 30, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+10B(0.00%) 🔺+5B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@greptile-apps

greptile-apps Bot commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This PR fixes a bug where tooltips could be opened by focusing a disabled trigger, making focus behavior consistent with hover behavior. The fix moves the useFocus hook from TooltipRoot to TooltipTrigger, allowing per-trigger control of focus behavior and properly respecting the disabled prop.

Changes:

  • Moved focus interaction handling from root to trigger level, following the same pattern as PreviewCardTrigger
  • The useFocus hook now respects the trigger's disabled prop, preventing focus from opening the tooltip when disabled
  • Added test coverage for the new behavior

Confidence Score: 5/5

  • This PR is safe to merge with no issues found
  • The implementation correctly fixes the bug by moving focus handling to the trigger level, follows established patterns in the codebase (PreviewCardTrigger), and includes comprehensive test coverage
  • No files require special attention

Important Files Changed

Filename Overview
packages/react/src/tooltip/root/TooltipRoot.tsx Removed useFocus hook and its import, moving focus handling to trigger level
packages/react/src/tooltip/trigger/TooltipTrigger.tsx Added useFocus hook with disabled check and applied focus props to trigger element
packages/react/src/tooltip/root/TooltipRoot.test.tsx Added test case verifying tooltip doesn't open on focus when trigger is disabled

@netlify

netlify Bot commented Jan 30, 2026

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 83f6263
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/697c9e7d01b93c0008f841c3
😎 Deploy Preview https://deploy-preview-3902--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks atomiks changed the title [tooltip] Prevent opening a tolltip on focusing a disabled Trigger [tooltip] Prevent opening when focusing a disabled Trigger Feb 1, 2026
@michaldudak
michaldudak merged commit 609c7b3 into mui:master Feb 9, 2026
9 checks passed
@michaldudak
michaldudak deleted the fix-tooltip-disabled-focus branch February 9, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: tooltip Changes related to the tooltip component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[tooltip] Allow disabling a Tooltip.Trigger when using detached triggers

3 participants