Skip to content

CP-13691: Patch scrollToTop#3657

Closed
ruijialin-avalabs wants to merge 4 commits intomainfrom
fixScrollToTop
Closed

CP-13691: Patch scrollToTop#3657
ruijialin-avalabs wants to merge 4 commits intomainfrom
fixScrollToTop

Conversation

@ruijialin-avalabs
Copy link
Contributor

@ruijialin-avalabs ruijialin-avalabs commented Mar 18, 2026

Description

iOS: 7779
Android: 7780

Ticket: CP-13691

Please provide:

This PR updates the local patch-package patch for react-native-collapsible-tab-view@9.0.0-rc.0 to add imperative ref methods intended to resync scroll state and programmatically scroll the active tab to the top.

Changes:

  • Add scrollResync() and scrollToTop() to the collapsible tab view ref API and TypeScript typings.
  • Implement scrollToTop() by resetting shared scroll values and issuing a UI-thread scroll command.
  • Modify the Reanimated useFrameCallback scroll sync behavior (attempted throttling).

Screenshots/Videos

Include relevant screenshots or screen recordings of iOS and Android.

Testing

Dev Testing (if applicable)

  • Provide steps to test the happy path of your feature
  • Provide steps to test edge cases and error states
  • Trigger a build on bitrise and reference it here
  • Move the ticket into the "Testing" column on Jira

QA Testing (if applicable)

  • Provide instructions for QA to test this feature thoroughly
  • State expected behavior / acceptance criteria

Checklist

Please check all that apply (if applicable)

  • I have performed a self-review of my code
  • I have verified the code works
  • I have included screenshots / videos of android and ios
  • I have added testing steps
  • I have added/updated necessary unit tests
  • I have updated the documentation

Copilot AI review requested due to automatic review settings March 18, 2026 18:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the local patch-package patch for react-native-collapsible-tab-view@9.0.0-rc.0 to add imperative ref methods intended to resync scroll state and programmatically scroll the active tab to the top.

Changes:

  • Add scrollResync() and scrollToTop() to the collapsible tab view ref API and TypeScript typings.
  • Implement scrollToTop() by resetting shared scroll values and issuing a UI-thread scroll command.
  • Modify the Reanimated useFrameCallback scroll sync behavior (attempted throttling).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

atn4z7
atn4z7 previously approved these changes Mar 18, 2026
@ruijialin-avalabs ruijialin-avalabs changed the title Patch scrollToTop CP-13691: Patch scrollToTop Mar 18, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Ray Lin <137183702+ruijialin-avalabs@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 18, 2026 19:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the local patch-package patch for react-native-collapsible-tab-view@9.0.0-rc.0 to expose new imperative ref methods intended to resync scroll state and programmatically scroll the active tab to the top.

Changes:

  • Add scrollResync() and scrollToTop() to the Collapsible Tab View ref API (runtime + typings).
  • Implement scrollToTop() by resetting shared scroll values and issuing a UI-thread scroll command.
  • Modify Reanimated useFrameCallback scroll syncing behavior with an attempted throttle.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

atn4z7
atn4z7 previously approved these changes Mar 18, 2026
Copilot AI review requested due to automatic review settings March 18, 2026 21:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the local patch-package patch for react-native-collapsible-tab-view@9.0.0-rc.0 to extend the tab view’s imperative ref API and adjust scroll sync behavior, aimed at resyncing scroll state and enabling programmatic “scroll active tab to top”.

Changes:

  • Adds a new scrollToTop() imperative ref method (implementation + typings).
  • Resets shared scroll values and issues a UI-thread scroll command when scrollToTop() is called.
  • Modifies the Reanimated useFrameCallback scroll sync behavior to throttle sync calls.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 32 to 37
@@ -11,6 +11,8 @@ export type RefHandler<T extends TabName = TabName> = {
setIndex: (index: number) => boolean;
getFocusedTab: () => T;
getCurrentIndex: () => number;
+ scrollResync: () => void;
+ scrollToTop: () => void;
};
Comment on lines +47 to 54
const lastSyncBucketRef = React.useRef(0)
const syncScrollFrame = useFrameCallback(({ timeSinceFirstFrame }) => {
- syncCurrentTabScrollPosition()
+ if (timeSinceFirstFrame % 100 === 0) {
+ const bucket = Math.floor(timeSinceFirstFrame / 100)
+ if (bucket !== lastSyncBucketRef.current) {
+ lastSyncBucketRef.current = bucket
+ syncCurrentTabScrollPosition()
+ }
Comment on lines +5 to +27
@@ -233,7 +233,24 @@ export const Container = React.memo(
getCurrentIndex: () => {
return index.value;
- }
- }), // eslint-disable-next-line react-hooks/exhaustive-deps
- [onTabPress]);
+ },
+ scrollToTop: () => {
+ scrollYCurrent.value = 0;
+ const resetMap = {};
+ for (const name of tabNamesArray) {
+ resetMap[name] = 0;
+ }
+ scrollY.value = { ...scrollY.value, ...resetMap };
+ const currentName = tabNames.value[index.value];
+ const ref = refMap[currentName];
+ if (ref) {
+ runOnUISync(scrollToImpl, ref, 0, -contentInset, false);
+ }
+ toggleSyncScrollFrame(true);
+ }
+ }), // eslint-disable-next-line react-hooks/exhaustive-deps
+ [onTabPress, toggleSyncScrollFrame]);
Comment on lines 58 to 75
@@ -42,15 +68,17 @@
+ scrollY.value = { ...scrollY.value, ...resetMap }
+ const currentName = tabNames.value[index.value]
+ const ref = refMap[currentName]
+ runOnUISync(scrollToImpl, ref, 0, -contentInset, false)
+ if (ref) {
+ runOnUISync(scrollToImpl, ref, 0, -contentInset, false)
+ }
+ toggleSyncScrollFrame(true)
+ },
Comment on lines 87 to 92
@@ -30,6 +30,8 @@ export type RefHandler<T extends TabName = TabName> = {
setIndex: (index: number) => boolean
getFocusedTab: () => T
getCurrentIndex: () => number
+ scrollResync: () => void
+ scrollToTop: () => void
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants