Skip to content

Commit c470288

Browse files
fix(scrollview): honor programmatic scrollTo when scrollEnabled={false} (#16336)
scrollEnabled={false} must only disable user scroll gestures, matching iOS and Android where setContentOffset / scrollToOffset still work when scrolling is disabled. The scrollTo command (and scrollToIndex / scrollToOffset, which route through it) previously hit a scrollEnabled early-return and was silently dropped. User-gesture input is gated separately via m_scrollVisual.ScrollEnabled (set from scrollEnabled in updateProps), so honoring a programmatic scroll here does not re-enable user scrolling. main-branch twin of #16304 (0.83-stable).
1 parent c69cf55 commit c470288

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"type":"prerelease","dependentChangeType":"patch","email":"collindanielschneide@gmail.com","packageName":"react-native-windows","comment":"Honor programmatic scrollTo when scrollEnabled={false}, matching iOS/Android"}

vnext/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,10 +1192,14 @@ void ScrollViewComponentView::HandleCommand(const winrt::Microsoft::ReactNative:
11921192
}
11931193

11941194
void ScrollViewComponentView::scrollTo(winrt::Windows::Foundation::Numerics::float3 offset, bool animate) noexcept {
1195-
if (!std::static_pointer_cast<const facebook::react::ScrollViewProps>(viewProps())->scrollEnabled) {
1196-
return;
1197-
}
1198-
1195+
// scrollEnabled={false} must only disable *user* scroll gestures, matching
1196+
// iOS and Android where setContentOffset / scrollToOffset still work when
1197+
// scrolling is disabled. Programmatic scrolls - the scrollTo command, and
1198+
// scrollToIndex / scrollToOffset which route through it - previously hit a
1199+
// scrollEnabled early-return here and were silently dropped. User-gesture
1200+
// input is gated separately (m_scrollVisual.ScrollEnabled, set from
1201+
// scrollEnabled in updateProps), so it is safe to always honor a
1202+
// programmatic scroll here.
11991203
m_scrollVisual.TryUpdatePosition(offset, animate);
12001204
}
12011205

0 commit comments

Comments
 (0)