From e14cdf6a5b34bce43f15e5da65f4fcd458ef216c Mon Sep 17 00:00:00 2001 From: shubhamguptadream11 Date: Mon, 30 Sep 2024 08:04:36 -0700 Subject: [PATCH] fix(iOS): title and title color handling added for refresh control (#46655) Summary: Solve a part of this issue: https://github.com/facebook/react-native/issues/46631 ## Changelog: [IOS] [CHANGED] - Passed correct title and titleColor prop to updateTitle function **What's the Issue:** When updating the PullToRefreshViewProps in a React Native iOS app, changes to the title and titleColor were not being reflected properly in the RefreshControl. This happened because the function responsible for updating the title (_updateTitle) was not always receiving the correct or updated values for title and titleColor. **Updated `_updateTitle` function:** The _updateTitle method was modified to accept both title and titleColor as parameters. This ensures that the latest values are always used when updating the refresh control's attributedTitle. If the title is empty, the attributedTitle is cleared by setting it to nil. Otherwise, both the title and titleColor (if present) are applied correctly. Pull Request resolved: https://github.com/facebook/react-native/pull/46655 Test Plan: **Without fix:** https://github.com/user-attachments/assets/8a83c247-bf78-4080-bdc1-ac5a852481e8 **With Fix:** https://github.com/user-attachments/assets/52e2495a-4419-41d1-b308-acb64600f9f7 Reviewed By: javache Differential Revision: D63466516 Pulled By: cipolleschi fbshipit-source-id: fef61a003b658b20a25b61b6d07ee9fe0750dae7 --- .../ScrollView/RCTPullToRefreshViewComponentView.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm index 704b2e95ec4730..3a5679ea5dd083 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm @@ -101,11 +101,11 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & needsUpdateTitle = YES; } + [super updateProps:props oldProps:oldProps]; + if (needsUpdateTitle) { [self _updateTitle]; } - - [super updateProps:props oldProps:oldProps]; } #pragma mark -