Skip to content

fix(VirtualizedList): sync virtualization logic with local direction style - #55481

Closed
Hector-Zhuang wants to merge 1 commit into
react:mainfrom
Hector-Zhuang:fix/55433
Closed

fix(VirtualizedList): sync virtualization logic with local direction style#55481
Hector-Zhuang wants to merge 1 commit into
react:mainfrom
Hector-Zhuang:fix/55433

Conversation

@Hector-Zhuang

Copy link
Copy Markdown
Contributor

Summary:

This commit fixes the blank rendering and behavior issue that occurs when a VirtualizedList is used in an RTL environment but explicitly styled as LTR.

The root cause was a mismatch between the JS-level coordinate normalization and the Native-level layout direction. While the native ScrollView rendered as LTR, the JS logic still applied RTL mirror calculations based on the global I18nManager state. This issue occurs on both iOS and Android.

Changelog:

[GENERAL] [FIXED] - Synchronize VirtualizedList coordinate logic with local direction style to fix blank rendering in RTL environments.

Test Plan:

  1. Environment: Set device/emulator system language to an RTL language (e.g., Arabic).
  2. render this component
<FlatList
  horizontal
  data={Array.from({length: 100}, (_, i) => ({id: i}))}
  renderItem={({item}) => (
    <View style={{width: 100, height: 100, backgroundColor: 'red', margin: 5}} />
  )}
  style={{direction: 'ltr'}}
/>

Expected Behavior:

Rendering: All items are rendered correctly during scroll.

Interaction: The scroll origin is at the left, and swiping follows LTR physics, matching the visual layout.

Actual Behavior (Before Fix):

Only the first few items appear; the rest are blank.

Related Issue

#55433

…style

Summary:
This commit fixes the blank rendering issue (Issue react#55433) that occurs when a
VirtualizedList is used in an RTL environment but explicitly styled as LTR.

The root cause was a mismatch between the JS-level coordinate normalization
and the Native-level layout direction. While the native ScrollView rendered
as LTR, the JS logic still applied RTL mirror calculations based on the
global I18nManager state.

Changes:
1. Updated `_orientation()` to prioritize the component's `style.direction`
   over the global `I18nManager.isRTL` setting.
2. In `render()`, explicitly calculated an `orientationStyle` based on the
   resolved direction and injected it into the ScrollView's style array.
3. This ensures that `_offsetFromScrollEvent` always uses a coordinate system
   that is perfectly aligned with the actual rendered layout.

Fixes: react#55433
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 9, 2026
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Feb 9, 2026
@meta-codesync

meta-codesync Bot commented Feb 9, 2026

Copy link
Copy Markdown

@CalixTang has imported this pull request. If you are a Meta employee, you can view this in D92766500.

@react-native-bot

Copy link
Copy Markdown
Collaborator

This PR is stale because it has been open for 180 days with no activity. It will be closed in 7 days unless you comment on it or remove the "Stale" label.

@react-native-bot react-native-bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 9, 2026
@react-native-bot

Copy link
Copy Markdown
Collaborator

This PR was closed because it has been stalled for 7 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. Stale There has been a lack of activity on this issue and it may be closed soon.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants