Something went wrong. Try again.
Mirror — see github.com/blacksky-algorithms/blacksky.community
Something went wrong. Try again.
7.5 kB · 174 lines
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mmindex 60160ef..fb646fe 100644--- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm+++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm@@ -42,6 +42,32 @@ - (void)setRefreshing:(BOOL)refreshing @implementation RCTPullToRefreshViewComponentView { UIRefreshControl *_refreshControl; RCTScrollViewComponentView *__weak _scrollViewComponentView;+ /*+ * Deferred props: updateProps runs during the Create mount mutation, before+ * _attach puts the control on the scroll view, and writes to a detached+ * UIRefreshControl are hazardous:+ *+ * - tintColor: writing it to a detached control permanently suppresses the+ * pull-to-refresh trigger haptic on iOS 17.4++ * (https://github.com/facebook/react-native/issues/43388).+ *+ * - progressViewOffset (the bounds.origin shift): on iOS 26 the control's+ * _UIRefreshControlModernContentView positions itself at whatever+ * bounds.origin it observes when it is CREATED - at insertion into the+ * scroll view, or earlier if a pre-attach property write materializes it -+ * and keeps that y forever (width tracks, y never re-pins; verified via+ * on-device frame logging, Aug 2026). A pre-attach shift is therefore+ * baked into the content view's own frame and cancelled exactly, hiding+ * the spinner. Applied post-attach, the content view has already been+ * created at origin 0 and the same bounds shift works as intended.+ *+ * Both props are parked here and applied only once the control is inside+ * the scroll view.+ */+ UIColor *_pendingTintColor;+ BOOL _hasPendingTintColor;+ CGFloat _pendingProgressViewOffset;+ BOOL _hasPendingProgressViewOffset; // This variable keeps track of whether the view is recycled or not. Once the view is recycled, the component // creates a new instance of UIRefreshControl, resetting the native props to the default values. // However, when recycling, we are keeping around the old _props. The flag is used to force the application@@ -79,10 +105,25 @@ + (ComponentDescriptorProvider)componentDescriptorProvider return concreteComponentDescriptorProvider<PullToRefreshViewComponentDescriptor>(); } +// Recycled instances get all props force-applied in updateProps, which runs+// before the new UIRefreshControl is inserted into the scroll view hierarchy;+// touching the control that early suppresses the pull-to-refresh haptic on+// iOS 17.4+ (react-native#43388). Opting out of recycling keeps every mount on+// the untouched-before-attach path. Refresh controls are rare and cheap, so+// losing recycling for them is negligible.++ (BOOL)shouldBeRecycled+{+ return NO;+}+ - (void)prepareForRecycle { [super prepareForRecycle]; _scrollViewComponentView = nil;+ _pendingTintColor = nil;+ _hasPendingTintColor = NO;+ _pendingProgressViewOffset = 0;+ _hasPendingProgressViewOffset = NO; [self _initializeUIRefreshControl]; _recycled = YES; }@@ -93,7 +134,8 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & const auto &newConcreteProps = static_cast<const PullToRefreshViewProps &>(*props); if (_recycled || newConcreteProps.tintColor != oldConcreteProps.tintColor) {- _refreshControl.tintColor = RCTUIColorFromSharedColor(newConcreteProps.tintColor);+ // Deferred until the control is inside the scroll view (#43388).+ [self _updateTintColor:RCTUIColorFromSharedColor(newConcreteProps.tintColor)]; } if (_recycled || newConcreteProps.progressViewOffset != oldConcreteProps.progressViewOffset) {@@ -141,11 +183,50 @@ - (void)handleUIControlEventValueChanged - (void)_updateProgressViewOffset:(Float)progressViewOffset {+ _pendingProgressViewOffset = progressViewOffset;+ _hasPendingProgressViewOffset = YES;+ // Applies immediately for runtime changes while the control is attached;+ // pre-attach sets wait until the control is inside the scroll view (see the+ // _pendingProgressViewOffset declaration).+ [self _applyPendingProgressViewOffsetIfPossible];+ if (_hasPendingProgressViewOffset) {+ [self setNeedsLayout];+ }+}++- (void)_applyPendingProgressViewOffsetIfPossible+{+ if (!_hasPendingProgressViewOffset || ![_refreshControl.superview isKindOfClass:[UIScrollView class]]) {+ return;+ } _refreshControl.bounds = CGRectMake( _refreshControl.bounds.origin.x,- -progressViewOffset,+ -_pendingProgressViewOffset, _refreshControl.bounds.size.width, _refreshControl.bounds.size.height);+ _hasPendingProgressViewOffset = NO;+}++- (void)_updateTintColor:(UIColor *)tintColor+{+ _pendingTintColor = tintColor;+ _hasPendingTintColor = YES;+ // Applies immediately for runtime changes while the control is attached;+ // pre-attach sets wait until the control is inside the scroll view.+ [self _applyPendingTintColorIfPossible];+ if (_hasPendingTintColor) {+ [self setNeedsLayout];+ }+}++- (void)_applyPendingTintColorIfPossible+{+ if (!_hasPendingTintColor || ![_refreshControl.superview isKindOfClass:[UIScrollView class]]) {+ return;+ }+ _refreshControl.tintColor = _pendingTintColor;+ _pendingTintColor = nil;+ _hasPendingTintColor = NO; } - (void)_updateTitle@@ -153,7 +234,12 @@ - (void)_updateTitle const auto &concreteProps = static_cast<const PullToRefreshViewProps &>(*_props); if (concreteProps.title.empty()) {- _refreshControl.attributedTitle = nil;+ // Avoid touching the control when there is nothing to clear - writing+ // attributedTitle (even nil) before the control is in the scroll view+ // hierarchy can suppress the pull-to-refresh haptic (#43388).+ if (_refreshControl.attributedTitle != nil) {+ _refreshControl.attributedTitle = nil;+ } return; } @@ -172,6 +258,18 @@ - (void)layoutSubviews { [super layoutSubviews]; + /*+ * Fallback for the pending props: _attach applies them right after the+ * refreshControl assignment (insertion is synchronous there on current iOS),+ * but should UIKit ever defer the insertion to a later layout pass, re-arm+ * and retry until the control is actually inside the scroll view.+ */+ [self _applyPendingTintColorIfPossible];+ [self _applyPendingProgressViewOffsetIfPossible];+ if ((_hasPendingTintColor || _hasPendingProgressViewOffset) && _scrollViewComponentView != nil) {+ [self setNeedsLayout];+ }+ // Attempts to begin refreshing before the initial layout are ignored by _refreshControl. So if the control is // refreshing when mounted, we need to call beginRefreshing in layoutSubviews or it won't work. if (self.window) {@@ -209,6 +307,15 @@ - (void)_attach // This ensures that layoutSubviews is called. Without this, recycled instances won't refresh on mount [self setNeedsLayout];++ /*+ * The assignment above inserts the control (and creates its content view)+ * synchronously on current iOS - verified via frame logging - so the+ * pending props can be applied immediately. layoutSubviews is the fallback+ * if insertion is ever deferred.+ */+ [self _applyPendingTintColorIfPossible];+ [self _applyPendingProgressViewOffsetIfPossible]; } }