Fix tooltip truncation for buttons and badges in New Architecture #736
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.
Problem
Tooltips were being truncated when hovering over various UI elements throughout the React Native Gallery application, affecting user experience and accessibility. The truncation occurred on:
Users could not see the full tooltip text, which violated accessibility guidelines (MAS 1.4.13 – Content on Hover or Focus) and created confusion about button purposes.
Root Cause
React Native Windows tooltips use the XAML ToolTip control, which has a default maximum width constraint. When tooltip text exceeded this default width, it would truncate in the middle of words or even characters, rather than wrapping to multiple lines.
Solution
Added
tooltipProperties={{MaxWidth: 500}}to all components using tooltips in the New Architecture version only. This Windows-specific prop passes theMaxWidthproperty to the underlying XAML ToolTip control, allowing tooltips to expand up to 500 pixels wide before wrapping text. This prevents truncation while maintaining reasonable tooltip dimensions.Changes
Modified 5 component files in the New Architecture version:
New Architecture:
NewArch/src/components/CopyToClipboard.tsx- Copy to clipboard buttonNewArch/src/components/Badge.tsx- Core Component and other badgesNewArch/src/components/ScreenWrapper.tsx- Navigation menu expand buttonNewArch/src/components/PageScroller.tsx- Scroll navigation buttonsNewArch/src/components/Controls.tsx- Documentation hyperlinksEach change adds a single line to set the tooltip properties, following the existing code patterns.
Testing
Impact
This fix improves the New Architecture version:
Fixes #704
Original prompt
Fixes #704
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
Microsoft Reviewers: Open in CodeFlow