Skip to content

fix(Table): mirror the row-expansion chevron under RTL - #5153

Merged
humbertovirtudes merged 2 commits into
meta:mainfrom
HelloOjasMutreja:fix/table-row-expansion-rtl-chevron
Aug 18, 2026
Merged

humbertovirtudes merged 2 commits into
meta:mainfrom
HelloOjasMutreja:fix/table-row-expansion-rtl-chevron

Conversation

@HelloOjasMutreja

Copy link
Copy Markdown
Contributor

Summary

Closes the tablerowexpansion finding in #5141 (weekly full-suite RTL audit, D1 icon-mirror).

Evidence

useTableRowExpansion.tsx's chevron rotated on expand with zero RTL handling:

chevronExpanded: {
  transform: 'rotate(90deg)',
},

No :is([dir="rtl"] *) variant at all, so the directional glyph pointed the same way regardless of text direction.

What I checked before fixing

TreeListItem.tsx's chevron is the exact same shape (rotate + directional glyph) and already handles this correctly:

chevronExpanded: {
  transform: {
    default: 'rotate(90deg)',
    ':is([dir="rtl"] *)': 'scaleX(-1) rotate(90deg)',
  },
},

with a comment explaining why the mirror is folded into each state's own transform rather than living on a separate wrapper: both are transform, so on one element the later declaration would win.

Fix

Applied the identical pattern to TableRowExpansion's chevron: chevronExpanded/chevronCollapsed variants, applied unconditionally based on state (matching TreeListItem's JSX callsite pattern) instead of the previous isExpanded && expansionStyles.chevronExpanded.

Also fixed a second, separate chevron in the same file: the row's context-menu action icon swaps between chevronDown (expanded, no mirroring needed since down is direction-agnostic) and chevronRight (collapsed, directional) instead of rotating. Applied rtlStyles.mirror to the collapsed state, matching the convention already used for static directional chevrons in Pagination, Carousel, Lightbox, and Calendar.

On the treelist finding in #5141

Checked: TreeListItem.tsx is the only chevron render site anywhere under TreeList/, and it already has the exact fold-into-transform mirror pattern (landed in #4838, well before this audit run). I couldn't find anything to fix there. The audit's treelist finding may be stale relative to that PR, or probing a state (e.g. an item this specific run's story couldn't expand) that a source-level check can't reproduce. Flagging this rather than guessing at a fix for code that already looks correct.

Test notes

Existing useTableRowExpansion.test.tsx suite (13 tests) passes unchanged. This codebase verifies RTL mirroring via the separate Storybook-based rtl-audit.mjs tool rather than per-component unit tests (confirmed: even TreeListItem, the reference-correct implementation, has no RTL-specific unit test), so I didn't invent a new test type here, staying consistent with that convention. Verification is source-level: the new code is an exact match of TreeListItem's already-shipped, already-audited-clean pattern.

Test plan

  • vitest run on useTableRowExpansion.test.tsx: 13/13 passing (no regression)
  • eslint clean on touched file
  • tsc --noEmit: no new errors (four pre-existing, unrelated renderExpanded errors confirmed present on unmodified upstream/main too)
  • Changeset added
  • Pattern verified against TreeListItem.tsx's identical, already-shipped fix

The row-expansion chevron rotated 90deg on expand with no RTL
handling at all, so the glyph pointed the same direction regardless
of text direction. Flagged by the weekly full-suite RTL audit (meta#5141,
D1 icon-mirror) against TableRowExpansion and TreeList.

TreeListItem's chevron already has the correct pattern for this exact
shape (rotate + directional glyph): fold the RTL mirror into each
state's own transform rather than a separate wrapper, since both are
`transform` and a later declaration on the same element would win.
Applied the identical pattern here.

Also fixed the context-menu action's icon, which swaps between
chevronDown (expanded, no mirroring needed) and chevronRight
(collapsed, directional) instead of rotating -- chevronRight needs
rtlStyles.mirror in the collapsed state, matching the convention used
by Pagination/Carousel/Lightbox/Calendar for static directional
chevrons.

TreeList's own instance already has the correct mirror (verified: it
is the only chevron render site in that directory, landed in meta#4838,
uses the exact fold-into-transform pattern this PR now matches) --
the audit's "treelist" finding may be stale or probing a state this
source-level check can't reproduce; nothing to fix there that I could
find.
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Aug 17, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 17, 2026
@vercel

vercel Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 17, 2026 4:20pm

Request Review

@HelloOjasMutreja

Copy link
Copy Markdown
Contributor Author

Following up on this with the before/after visual this PR was missing (it's a rendering change, chevron rotation/mirror, so it should have shipped with one originally).

Captured from the live Core/TableRowExpansion Storybook story, toggling the direction toolbar control:

RTL, before this fix: the collapsed-row chevron still points right, the same direction as LTR, instead of toward where content actually expands under RTL.

RTL before

RTL, after this fix: the collapsed-row chevron correctly mirrors to point left.

RTL after

LTR, unchanged for reference:

LTR

@humbertovirtudes humbertovirtudes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great fix thanks for the contribution!

@humbertovirtudes
humbertovirtudes enabled auto-merge (squash) August 18, 2026 22:28
@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Aug 18, 2026
@humbertovirtudes
humbertovirtudes merged commit ea7fc8c into meta:main Aug 18, 2026
21 of 23 checks passed
@humbertovirtudes

Copy link
Copy Markdown
Contributor

Can you help address the failed checks ?

This branch was successfully deployed

1 active deployment
Preview — 1f1a4674 Deployed Aug 17, 2026 by vercel[bot]
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 Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants