-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Fix: force FlashList to use natural DOM order on web #85825
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
Open
sharabai
wants to merge
3
commits into
Expensify:main
Choose a base branch
from
software-mansion-labs:fix/flash-list/DOM-order
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+35
−0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
27 changes: 27 additions & 0 deletions
27
patches/@shopify/flash-list/@shopify+flash-list+2.3.0+003+sort-for-natural-DOM-order.patch
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,27 @@ | ||
| diff --git a/node_modules/@shopify/flash-list/dist/recyclerview/ViewHolderCollection.js b/node_modules/@shopify/flash-list/dist/recyclerview/ViewHolderCollection.js | ||
| index 8e3db51..85738f0 100644 | ||
| --- a/node_modules/@shopify/flash-list/dist/recyclerview/ViewHolderCollection.js | ||
| +++ b/node_modules/@shopify/flash-list/dist/recyclerview/ViewHolderCollection.js | ||
| @@ -7,6 +7,7 @@ import React, { useEffect, useImperativeHandle, useLayoutEffect } from "react"; | ||
| import { ViewHolder } from "./ViewHolder"; | ||
| import { CompatView } from "./components/CompatView"; | ||
| import { useRecyclerViewContext } from "./RecyclerViewContextProvider"; | ||
| +import { Platform } from "react-native"; | ||
| /** | ||
| * ViewHolderCollection component that manages the rendering of multiple ViewHolder instances | ||
| * and handles layout updates for the entire collection | ||
| @@ -72,9 +73,13 @@ export const ViewHolderCollection = (props) => { | ||
| // return `${index} => ${reactKey}`; | ||
| // }) | ||
| // ); | ||
| + const renderEntries = Array.from(renderStack.entries()); | ||
| + if (Platform.OS === "web") { | ||
| + renderEntries.sort(([, a], [, b]) => a.index - b.index); | ||
| + } | ||
| return (React.createElement(CompatView, { style: hasData && containerStyle }, containerLayout && | ||
| hasData && | ||
| - Array.from(renderStack.entries(), ([reactKey, { index }]) => { | ||
| + renderEntries.map(([reactKey, { index }]) => { | ||
| const item = data[index]; | ||
| // Suppress separators for items in the last row to prevent | ||
| // height mismatch. The last data item has no separator (no | ||
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.
This sort always uses ascending
index, but FlashList still supportsinvertedon web (RecyclerView/ViewHolderreverse the visual order via the inverted transform helpers). In that mode the DOM will now be deterministically ordered opposite to what users see, so keyboard and screen-reader traversal stays backwards for any inverted FlashList even though this patch is meant to fix accessibility ordering. The web sort needs to account forinverted(and horizontal inverted) instead of always usinga.index - b.index.Useful? React with 👍 / 👎.
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.
We don't have yet any components that are using
invertedprop with FlashList. I did test it on FlashList 2.3.0 without the patch and let's just say inverted does a lot of things at once and navigation there looks weird in general. For example, list starts from the bottom and tabbing goes up, not down (without the patch). The patch does not change that behavior. Maybe it's warranted to come back to it when we have some components that do use that prop and reevaluate, but the behavior looks good to me at this point.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.
@VickyStash Can you please look into this when you use this prop?
Uh oh!
There was an error while loading. Please reload this page.
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.
Here is the PR #85114 where I'm working on migration main chat to FlashList with the inverted flag (P.S. I have three patches there as well). So what should I test specifically?
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.
FYI I've also tested this PR over the scenario when main chat (so expense details too) are migrated to FlashList, and I see some wrong ordering when I use voice over:
Monosnap.screencast.2026-03-20.09-32-05.mp4
But since FlashList is not used for the main chat in the current prod, I guess it can be solved later.
Just one question from me, does this PR then fixes the original issue for production? Since at this moment FlatList is used for main chat/expense details on prod?