Repository navigation
[CP Staging] Revert "Open linked message at top" #94470
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
Merged
mountiny
merged 1 commit into
main
from
revert-93403-VickyStash/feature/open-linked-message-centered
Jun 24, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
104 changes: 0 additions & 104 deletions
104
patches/@shopify/flash-list/@shopify+flash-list+2.3.0+013+improve-scroll-key-handling.patch
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import type {FlashListProps} from '@shopify/flash-list'; | ||
| import {useEffect, useState} from 'react'; | ||
|
|
||
| type FlashListScrollKeyProps<T> = { | ||
| /** The array of items to render in the list. */ | ||
| data: T[]; | ||
|
|
||
| /** Function that extracts a unique key for each item in the list. */ | ||
| keyExtractor: (item: T, index: number) => string; | ||
|
|
||
| /** Key of the item to initially scroll to when the list first renders. */ | ||
| initialScrollKey: string | null | undefined; | ||
|
|
||
| /** Callback invoked when the user scrolls close to the start of the list. */ | ||
| onStartReached: FlashListProps<T>['onStartReached']; | ||
|
|
||
| /** Whether the list should handle `maintainVisibleContentPosition` */ | ||
| shouldMaintainVisibleContentPosition?: boolean; | ||
| }; | ||
|
|
||
| export default function useFlashListScrollKey<T>({data, keyExtractor, initialScrollKey, onStartReached, shouldMaintainVisibleContentPosition}: FlashListScrollKeyProps<T>) { | ||
| const [isInitialRender, setIsInitialRender] = useState(!!initialScrollKey); | ||
| const [hasLinkingSettled, setHasLinkingSettled] = useState(!initialScrollKey); | ||
|
|
||
| // Two-frame handoff for deep-link: | ||
| // RAF 1: switch from sliced data to the full array — FlashList's default MVCP pins the | ||
| // linked item through the data swap. | ||
| // RAF 2: pinning has happened, disable MVCP so it doesn't cause later jumps. | ||
| useEffect(() => { | ||
| if (!isInitialRender) { | ||
| return; | ||
| } | ||
|
|
||
| // Without an anchor on this frame, we are not doing the deep-link slice handoff; clear the flag so a key that | ||
| // appears later (e.g. marking a message unread) cannot reuse the "first paint" slice path. | ||
| if (!initialScrollKey) { | ||
| // If the initial scroll key gets unset, we need to disable the initial render flag, | ||
| // otherwise the list will not render.. | ||
| // eslint-disable-next-line react-hooks/set-state-in-effect | ||
| setIsInitialRender(false); | ||
| return; | ||
| } | ||
|
|
||
| requestAnimationFrame(() => { | ||
| setIsInitialRender(false); | ||
| requestAnimationFrame(() => setHasLinkingSettled(true)); | ||
| }); | ||
| }, [isInitialRender, initialScrollKey]); | ||
|
|
||
| const maintainVisibleContentPosition: FlashListProps<T>['maintainVisibleContentPosition'] = {disabled: !shouldMaintainVisibleContentPosition && hasLinkingSettled}; | ||
|
|
||
| if (!isInitialRender || !initialScrollKey) { | ||
| return {displayedData: data, onStartReached, maintainVisibleContentPosition}; | ||
| } | ||
|
|
||
| const targetIndex = data.findIndex((item, index) => keyExtractor(item, index) === initialScrollKey); | ||
| if (targetIndex <= 0) { | ||
| return {displayedData: data, onStartReached, maintainVisibleContentPosition}; | ||
| } | ||
|
|
||
| // On the first render, slice from the target onward so the target item | ||
| // appears at the visual bottom of the inverted list — no scrolling needed. | ||
| return {displayedData: data.slice(targetIndex), onStartReached: () => {}, maintainVisibleContentPosition}; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
When opening a report to a linked/unread action that is already cached while
OpenReportis still loading, this second RAF marks the handoff as settled and disables MVCP after only two frames. SinceReportActionsListno longer holds the skeleton duringreportLoadingState.isLoadingInitialReportActions, the initial response can still merge adjacent actions after this point; those insertions are no longer anchored and can shift the target message out of view. Please keep the anchor/skeleton active until the initial report actions load completes.Useful? React with 👍 / 👎.