-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix XAML popup positioning and light dismiss in ScrollView (#15557) #15564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix XAML popup positioning and light dismiss in ScrollView (#15557) #15564
Conversation
…#15557) - Add SetXamlRoot() API on ContentIslandComponentView for 3rd party XAML components - Add DismissPopups() using VisualTreeHelper.GetOpenPopupsForXamlRoot() - Fire LayoutMetricsChanged on scroll to update popup positions - Dismiss child ContentIsland popups when scroll begins - Add ComboBox sample component demonstrating the pattern - Add xamlPopupBug test sample for playground-composition
sundaramramaswamy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address comments.
…#15557) - Set LocalToParentTransformMatrix synchronously before Connect() to fix initial position - Fire LayoutMetricsChanged on scroll to update position after scrolling - Add DismissPopupsRequest event for 3P components to implement light dismiss - Update ComboBox sample to use event-based approach (core remains XAML-agnostic)
Issue microsoft#15557: Fix popup positioning for XAML controls in ScrollView Bug 1 (Position Fix): - Convert getClientRect() physical pixels to DIPs by dividing by pointScaleFactor - LocalToParentTransformMatrix expects logical pixels (DIPs), not physical pixels - Update transform synchronously instead of async to avoid race conditions - Set initial transform in OnMounted() before Connect() Bug 2 (Light Dismiss Fix): - Add DismissPopupsRequest event for 3P components to handle popup dismissal - ScrollView fires event when scroll begins via DismissChildContentIslandPopups() - Core remains XAML-agnostic - 3P components handle their own popups
sundaramramaswamy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert formatting changes.
f0d7eb5 to
e8cfe99
Compare
vnext/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp
Show resolved
Hide resolved
vnext/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp
Outdated
Show resolved
Hide resolved
|
Assuming LocalToParentTransformMatrix is pretty cheap, the LocalToParentTransformMatrix changes look good. The light dismiss logic seems more wrong. This looks like we need additional hosting APIs from ContentIslands. ContentIslands should provide APIs to handle this kind of communication, and Xaml / RNW should talk to the new API. Xaml content islands should not have to know about RNW APIs - it breaks the ContentIsland encapsulation. |
vnext/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp
Outdated
Show resolved
Hide resolved
vnext/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp
Show resolved
Hide resolved
|
@acoates-ms I have addressed all comments, please review it. |
Fix XAML popup positioning and light dismiss in ScrollView (#15557)
Description
This PR fixes Issue #15557 - "Pop-ups of Xaml controls need positioning and dismissal"
When XAML controls with popups (like ComboBox, DatePicker, TimePicker) are hosted inside a React Native ScrollView via
ContentIslandComponentView, two bugs occur:Root Cause Analysis
Bug 1: Popup Position
ContentIslandComponentViewusesChildSiteLink.LocalToParentTransformMatrixfor popup positioninggetClientRect()returns values in physical pixels (scaled bypointScaleFactor), butLocalToParentTransformMatrixexpects logical pixels (DIPs)UIDispatcher().Post(), causing race conditions where popup opened with stale transform valuesConnect(), causing wrong position even without scrollingBug 2: Light Dismiss on Scroll
Solution
Bug 1 Fix: Popup Position After Scroll
getClientRect()values bypointScaleFactorbefore settingLocalToParentTransformMatrixUIDispatcher().Post()wrapper - update transform immediatelyLocalToParentTransformMatrixinOnMounted()beforeConnect()ScrollViewComponentViewfiresLayoutMetricsChangedevent when scroll position changesBug 2 Fix: Light Dismiss on Scroll (Optimized)
DismissPopupsRequestevent toContentIslandComponentViewScrollBeginDragevent toScrollViewComponentViewOnMounted(),ContentIslandComponentViewwalks up the tree once and registers forScrollBeginDragon all parentScrollViewComponentViewinstancesScrollViewComponentViewfires itsScrollBeginDragevent, which notifies only the registeredContentIslandComponentViewinstancesDismissPopupsRequestand dismiss their own popupsFiles Changed
Core Fix (vnext/Microsoft.ReactNative/)
Fabric/Composition/ContentIslandComponentView.cpp- DIP conversion, sync updates, register for parent ScrollView events during mountFabric/Composition/ContentIslandComponentView.h- Store scroll subscriptionsFabric/Composition/ScrollViewComponentView.cpp- Fire LayoutMetricsChanged on scroll, expose ScrollBeginDrag eventFabric/Composition/ScrollViewComponentView.h- ScrollBeginDrag eventCompositionComponentView.idl- Added DismissPopupsRequest event to ContentIslandComponentView, ScrollBeginDrag event to ScrollViewComponentViewTesting
XamlPopupReprosample in Playground##Screenshot
testingFix.mp4