Skip to content

Clamp Tooltip Position To Monitor - #16372

Open
Vineeth (vineethkuttan) wants to merge 3 commits into
mainfrom
tooltipfixmain
Open

Clamp Tooltip Position To Monitor#16372
Vineeth (vineethkuttan) wants to merge 3 commits into
mainfrom
tooltipfixmain

Conversation

@vineethkuttan

@vineethkuttan Vineeth (vineethkuttan) commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

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

  • Bug fix (non-breaking change which fixes an issue)

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 :
image

After :
image

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

@vineethkuttan
Vineeth (vineethkuttan) requested a review from a team as a code owner August 17, 2026 06:25
Copilot AI balanced review requested due to automatic review settings August 17, 2026 06:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants