You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR fixes tooltip behavior for detached triggers when moving between enabled/disabled triggers, and unifies the logic across hover and focus interactions.
What changed
Introduced a shared enabled-trigger check (isTargetInsideEnabledTrigger) used by hover and focus logic.
Updated hover handling so switching to a trigger marked with data-trigger-disabled no longer keeps the previous popup open.
Updated focus handling with the same rule, so focusing a disabled trigger closes an already-open tooltip.
Kept support for rendered native disabled buttons as valid triggers when the trigger itself is enabled.
Tests
Added tooltip detached-trigger regressions for:
hover to disabled trigger closes,
focus to disabled trigger closes,
rendered disabled button still switches/opens when trigger hover is enabled.
Result
Detached trigger behavior is now consistent and predictable:
Disabled triggers do not participate in hover/focus switching.
Enabled triggers rendered as disabled buttons still behave correctly.
This PR fixes tooltip behavior for detached triggers by ensuring disabled triggers don't participate in hover/focus switching. The implementation introduces a shared isTargetInsideEnabledTrigger helper that checks for the data-trigger-disabled attribute, unifying the logic across hover and focus interactions.
Key changes:
Added data-trigger-disabled attribute to disabled triggers
Refactored useFocus, useHoverReferenceInteraction, and useHoverFloatingInteraction to use the new helper
Disabled triggers now properly close tooltips when focused/hovered instead of keeping them open
Enabled triggers rendered as disabled buttons still work correctly
Added comprehensive test coverage for all scenarios
The implementation is clean and well-tested. The logic correctly distinguishes between the trigger's disabled state (controlled by the disabled prop) and the rendered element's disabled state (e.g., a native disabled button).
Confidence Score: 5/5
This PR is safe to merge with minimal risk
The implementation is well-designed with a clean separation of concerns. The new isTargetInsideEnabledTrigger helper centralizes the logic for checking enabled triggers, and all three interaction hooks consistently use it. The PR includes comprehensive test coverage for all scenarios (focus to disabled, hover to disabled, and rendered disabled buttons), and the logic correctly handles the distinction between trigger disabled state and rendered element disabled state. No issues found.
Adds isTargetInsideEnabledTrigger helper function to check if target is within enabled trigger, distinguishing between enabled and disabled triggers using data-trigger-disabled attribute
Refactors focus logic to use isTargetInsideEnabledTrigger instead of simple trigger checks, ensuring disabled triggers don't participate in focus switching
Refactors hover logic to use isTargetInsideEnabledTrigger, adds early return when enabled is false, ensuring disabled triggers don't participate in hover switching
"description": "Whether the trigger is disabled. If `true`, the tooltip will not open when interacting with this trigger.\nNote that this doesn't apply the `disabled` attribute to the trigger element.\nIf you want to disable the trigger element itself, you can pass the `disabled` prop to the trigger element via the `render` prop.",
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes tooltip behavior for detached triggers when moving between enabled/disabled triggers, and unifies the logic across hover and focus interactions.
What changed
isTargetInsideEnabledTrigger) used by hover and focus logic.data-trigger-disabledno longer keeps the previous popup open.Tests
Added tooltip detached-trigger regressions for:
Result
Detached trigger behavior is now consistent and predictable:
Closes #3468
Preview
https://deploy-preview-4049--base-ui.netlify.app/experiments/tooltip/disabled