[0.81] Clamp Tooltip Position To Monitor - #16371
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 windows to the nearest monitor’s work area.
Changes:
- Adds monitor-aware tooltip positioning and edge clamping.
- Uses the clamped coordinates when creating tooltip windows.
- 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 |
|---|---|
TooltipService.cpp |
Adds monitor-aware tooltip placement. |
| Change JSON | Records the patch release note. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
vnext/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp:161
- Capping these fields only shrinks the popup HWND; the
IDWriteTextLayoutwas already created with the original constraints andWM_PAINTstill renders that unchanged layout. Whenever either cap is hit, text outside the reduced client rect is therefore clipped, so an oversized tooltip is not actually fully visible. Resolve the monitor limits before creating the text layout (accounting for padding and scale), or recreate/update the layout with the capped content size and an explicit overflow/trimming policy before deriving the final window dimensions.
tooltipWidth = std::min(tooltipWidth, static_cast<int>(bounds.right - bounds.left));
tooltipHeight = std::min(tooltipHeight, static_cast<int>(bounds.bottom - bounds.top));
Vineeth (vineethkuttan)
force-pushed
the
tooltipfix
branch
from
August 17, 2026 06:17
2194144 to
d377514
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
vnext/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp:153
- Capping only these window dimensions does not resize the already-created
IDWriteTextLayout. If the measured tooltip exceeds the work area,CreateWindowgets the reduced size whileRenderTextstill draws the original larger layout, so text is clipped (and any existing ellipsis can remain outside the client area). Please apply the monitor-derived bounds to the layout constraints before creating/measuring the text layout, then clamp using those resulting dimensions.
// 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