fix(react-tooltip): dismiss tooltip when document becomes hidden#36023
fix(react-tooltip): dismiss tooltip when document becomes hidden#36023
Conversation
Agent-Logs-Url: https://github.com/microsoft/fluentui/sessions/f63f5a32-8d4d-4adc-8419-ab20ef41ac6f Co-authored-by: tudorpopams <97875118+tudorpopams@users.noreply.github.com>
📊 Bundle size reportUnchanged fixtures
|
|
Pull request demo site: URL |
| @@ -0,0 +1,7 @@ | |||
| { | |||
There was a problem hiding this comment.
🕵🏾♀️ visual changes to review in the Visual Change Report
vr-tests-react-components/Charts-DonutChart 1 screenshots
| Image Name | Diff(in Pixels) | Image Type |
|---|---|---|
| vr-tests-react-components/Charts-DonutChart.Dynamic - RTL.default.chromium.png | 5570 | Changed |
vr-tests-react-components/Positioning 2 screenshots
| Image Name | Diff(in Pixels) | Image Type |
|---|---|---|
| vr-tests-react-components/Positioning.Positioning end.chromium.png | 963 | Changed |
| vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png | 735 | Changed |
vr-tests-react-components/ProgressBar converged 3 screenshots
| Image Name | Diff(in Pixels) | Image Type |
|---|---|---|
| vr-tests-react-components/ProgressBar converged.Indeterminate + thickness - Dark Mode.default.chromium.png | 25 | Changed |
| vr-tests-react-components/ProgressBar converged.Indeterminate + thickness - High Contrast.default.chromium.png | 61 | Changed |
| vr-tests-react-components/ProgressBar converged.Indeterminate + thickness.default.chromium.png | 37 | Changed |
vr-tests-react-components/TagPicker 3 screenshots
| Image Name | Diff(in Pixels) | Image Type |
|---|---|---|
| vr-tests-react-components/TagPicker.disabled - Dark Mode.disabled input hover.chromium.png | 658 | Changed |
| vr-tests-react-components/TagPicker.disabled - RTL.chromium.png | 635 | Changed |
| vr-tests-react-components/TagPicker.disabled.disabled input hover.chromium.png | 677 | Changed |
There were 3 duplicate changes discarded. Check the build logs for more information.
| // Dismiss the tooltip when the document becomes hidden (e.g. tab backgrounded, | ||
| // app switched on mobile). The original trigger (hover/tap/focus) is no longer | ||
| // active in this case, so persisting the tooltip is a stale UI state. | ||
| // See https://github.com/microsoft/fluentui/issues/35301 |
Agent-Logs-Url: https://github.com/microsoft/fluentui/sessions/86e33d49-003c-4190-9a61-90a69bca5bc6 Co-authored-by: tudorpopams <97875118+tudorpopams@users.noreply.github.com>
PR Review: #36023 — fix(react-tooltip): dismiss tooltip when document becomes hiddenAuthor: app/copilot-swe-agent Confidence Score: 100/100Minimal, well-scoped WCAG-1.4.13-compliant fix. New listener is colocated with the existing FindingsBlockers (must fix before merge)none Warnings (should address)none Info (consider)
Category Breakdown
RecommendationAPPROVE The fix composes cleanly with existing tooltip teardown: the Posted via the |

On mobile, tapping a tooltip-wrapped link that opens a new tab leaves the tooltip stuck visible after returning to the original tab, because neither
pointerleavenorblurfires in that flow. Per WCAG 1.4.13 analysis in the issue thread, dismissing is correct here since the original hover/tap/focus trigger is no longer active.Changes
useTooltipBase.tsx: Inside the existing visibility-gateduseIsomorphicLayoutEffect(which already owns thekeydown/Escape listener), register avisibilitychangelistener ontargetDocumentfromuseFluent_unstable(). WhentargetDocument.visibilityState === 'hidden', call the samethisTooltip.hide()path used by Escape soonVisibleChangeand controlled-state semantics are preserved. Cleanup is colocated with the existingkeydownremoval.Tooltip.test.tsx: New test stubsdocument.visibilityStateto'hidden', dispatches avisibilitychangeevent, and assertsonVisibleChangefires with{ visible: false }.@fluentui/react-tooltip.Caveat
The reported bug is on iOS Safari / Mobile Edge. The Jest test verifies the dismiss path fires on
visibilitychangein jsdom; the actual iOS task-switcher flow needs manual verification by the reviewer on a real device.