Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

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

Ojas Mutrejaea7fc8cba338
diff --git a/.changeset/table-row-expansion-rtl-chevron.md b/.changeset/table-row-expansion-rtl-chevron.md
new file mode 100644
index 0000000000..e4b1289bb0
--- /dev/null
+++ b/.changeset/table-row-expansion-rtl-chevron.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] `Table`'s row-expansion chevron now mirrors correctly under RTL. It previously rotated on expand with no RTL handling at all, so the directional glyph pointed the same way regardless of text direction, matching the pattern already used by `TreeListItem`'s chevron.
+
+@HelloOjasMutreja
diff --git a/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx b/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx
index aecfe2c1a7..4656c1df5e 100644
--- a/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx
+++ b/packages/core/src/Table/plugins/rowExpansion/useTableRowExpansion.tsx
@@ -23,6 +23,7 @@ import {spacingVars, colorVars, radiusVars} from '../../../theme/tokens.stylex';
import {Icon} from '../../../Icon';
import {resolveContextActions} from '../../tableContextMenu';
import {useTranslator} from '../../../i18n';
+import {rtlStyles} from '../../../utils';
import type {
TablePlugin,
TableColumn,
@@ -92,8 +93,20 @@ const expansionStyles = stylex.create({
color: colorVars['--color-icon-primary'],
},
},
+ // The RTL mirror is folded into each state's transform rather than living
+ // on a parent span, matching TreeListItem's chevron (both are `transform`,
+ // so on one element the later value would win).
chevronExpanded: {
- transform: 'rotate(90deg)',
+ transform: {
+ default: 'rotate(90deg)',
+ ':is([dir="rtl"] *)': 'scaleX(-1) rotate(90deg)',
+ },
+ },
+ chevronCollapsed: {
+ transform: {
+ default: 'rotate(0deg)',
+ ':is([dir="rtl"] *)': 'scaleX(-1) rotate(0deg)',
+ },
},
expandedRow: {
backgroundColor: colorVars['--color-background-muted'],
@@ -121,7 +134,9 @@ function ExpansionChevron({
type="button"
{...stylex.props(
expansionStyles.chevronButton,
- isExpanded && expansionStyles.chevronExpanded,
+ isExpanded
+ ? expansionStyles.chevronExpanded
+ : expansionStyles.chevronCollapsed,
)}
onClick={e => {
e.stopPropagation();
@@ -249,6 +264,9 @@ export function useTableRowExpansion<T extends Record<string, unknown>>(
icon={isExpanded ? 'chevronDown' : 'chevronRight'}
size="xsm"
aria-hidden
+ // chevronDown needs no mirroring; chevronRight (collapsed,
+ // pointing toward the reveal direction) does.
+ xstyle={!isExpanded && rtlStyles.mirror}
/>
),
onSelect: () => onToggle(key),