Clamp Tooltip Position To Monitor - #16372
Open
Vineeth (vineethkuttan) wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Clamps Fabric tooltip popups to the nearest monitor’s work area.
Changes:
- Adds monitor-aware tooltip positioning and edge clamping.
- Adds a patch changelog entry.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
vnext/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp |
Clamps tooltip size and position to monitor bounds. |
change/react-native-windows-c28bfe9f-8c81-4316-aa52-c66fc1dc98d9.json |
Records the patch release change. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+150
to
+153
| // Cap the tooltip size to the work area so the position clamping below is guaranteed to keep | ||
| // the whole tooltip on-screen, even for unusually long tooltip text. | ||
| tooltipWidth = std::min(tooltipWidth, static_cast<int>(bounds.right - bounds.left)); | ||
| tooltipHeight = std::min(tooltipHeight, static_cast<int>(bounds.bottom - bounds.top)); |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fixes a P0 bug reported by the Kindle team where React Native Windows tooltips rendered near screen edges (e.g. icons in the top-right corner) get cut off / clipped instead of staying fully visible.
Type of Change
Why
TooltipTracker::ShowTooltip in TooltipService.cpp positioned the native tooltip popup window using only the cursor/anchor point ( pt.x - width/2 , pt.y - height - margin ), with no check against screen bounds. Tooltips anchored near a monitor edge could therefore render partially or fully outside the visible screen.
What
Added ClampTooltipPositionToMonitor() :
• Resolves the monitor nearest the anchor point via MonitorFromPoint + GetMonitorInfo(...).rcWork .
• Flips the tooltip below the anchor when there isn't enough room above (instead of clipping at the top).
• Clamps the final tooltip rect horizontally and vertically so it never extends past the monitor's work area.
ShowTooltip now uses this clamped position when creating the tooltip popup window, instead of the raw, unclamped offset.
This matches standard OS tooltip behavior (Win32/WinUI), where tooltips may extend beyond their owner window but are always kept fully within the visible screen.
Screenshots
Before :

After :

Testing
Tested in Playground
Changelog
Should this change be included in the release notes: yes
Clamp Tooltip Position according to the Monitor
Microsoft Reviewers: Open in CodeFlow