feat: support rtl direction#56
Conversation
|
@aojunhao123 is attempting to deploy a commit to the React Component Team on Vercel. A member of the Team first needs to authorize it. |
Walkthrough新增 ChangesRTL 方向支持
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Listy
participant VirtualList
participant RcVirtualList
participant RawList
Listy->>VirtualList: 传递 direction
VirtualList->>RcVirtualList: 传递 direction
Listy->>RawList: 传递 direction
RawList->>RawList: 设置 rc-listy-rtl 与 dir="rtl"
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces support for Right-to-Left (RTL) layout direction in the Listy component by adding a direction prop ('ltr' | 'rtl'). This prop is forwarded to both RawList (applying the dir attribute and -rtl class) and VirtualList. A demo, an example, and tests are added to verify this behavior. The reviewer suggested updating the documentation in README.md to show that the default value of direction is '-' (undefined/inherited) rather than 'ltr', to accurately reflect the implementation.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
771354c to
fa668ee
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/listy.behavior.test.tsx (1)
504-517: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win补充默认方向的测试覆盖。
当前测试验证了
direction: 'rtl'在两种渲染模式下的行为,但缺少direction未传入(默认)时的断言——即 raw list 不应有rc-listy-rtlclass 和dir属性。建议补充一个默认场景的测试以防止回归。✅ 建议补充的测试
it('applies dir and rtl class on the raw list', () => { const { container } = renderList({ virtual: false, direction: 'rtl' }); const holder = container.querySelector('.rc-listy') as HTMLDivElement; expect(holder).toHaveClass('rc-listy-rtl'); expect(holder).toHaveAttribute('dir', 'rtl'); }); + + it('does not apply rtl class or dir attribute by default', () => { + const { container } = renderList({ virtual: false }); + + const holder = container.querySelector('.rc-listy') as HTMLDivElement; + + expect(holder).not.toHaveClass('rc-listy-rtl'); + expect(holder).not.toHaveAttribute('dir'); + });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/listy.behavior.test.tsx` around lines 504 - 517, 补充默认方向的测试覆盖:在“applies dir and rtl class on the raw list”附近新增未传入 direction 的场景,使用 raw list 渲染并断言容器不包含 rc-listy-rtl class 且不具有 dir 属性;保留现有 direction: 'rtl' 的断言不变。
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/listy.behavior.test.tsx`:
- Around line 504-517: 补充默认方向的测试覆盖:在“applies dir and rtl class on the raw
list”附近新增未传入 direction 的场景,使用 raw list 渲染并断言容器不包含 rc-listy-rtl class 且不具有 dir
属性;保留现有 direction: 'rtl' 的断言不变。
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ec7192d9-0dbc-47c1-afc9-20d93bd4544c
📒 Files selected for processing (7)
README.mddocs/demos/rtl.mddocs/examples/rtl.tsxsrc/List.tsxsrc/RawList/index.tsxsrc/VirtualList/index.tsxtests/listy.behavior.test.tsx
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #56 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 8 8
Lines 211 211
Branches 62 62
=========================================
Hits 211 211 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Add a `direction?: 'ltr' | 'rtl'` prop threaded to both list backends: - VirtualList forwards `direction` to the underlying `@rc-component/virtual-list`, which sets `dir`, the `rc-listy-rtl` class, flips the scrollbar, and exposes `rtl` to sticky-header logic. - RawList sets `dir` and the `rc-listy-rtl` class on its root for parity. No CSS mirroring needed — the sticky/fixed group header already spans the full width (`left:0; right:0`), so it is direction-agnostic. Adds an RTL demo, README prop docs, and tests covering both backends.
fa668ee to
eab2024
Compare
Summary by CodeRabbit
新功能
direction属性,支持ltr(从左到右)和rtl(从右到左)布局。文档
direction属性说明及默认值。测试