Skip to content

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

TypeScript

fix(core): RTL Phase 4b — ChatMessageBubble tail, Table sticky-column shadows, ResizeHandle (#4549)

nynexman4464e00a241677d3
diff --git a/.changeset/rtl-phase4b-behavioral.md b/.changeset/rtl-phase4b-behavioral.md
new file mode 100644
index 0000000000..f86693d355
--- /dev/null
+++ b/.changeset/rtl-phase4b-behavioral.md
@@ -0,0 +1,6 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] RTL Phase 4b behavioral fixes: ChatMessageBubble grouped-bubble tail corners now use logical border radii so the tail follows reading direction (mirrors under RTL, text unaffected); Table sticky-column shadows make their `translateX` and gradient direction-aware so the shadow fades from the pinned edge toward scrolled content in both LTR and RTL instead of rendering inside-out, and gate shadow visibility on `Math.abs(scrollLeft)` so the start/end shadows still appear under RTL (where spec-compliant browsers report a negative `scrollLeft`); ResizeHandle's hit-area bias is now direction-aware (mirrors about center under RTL) and the pointer-drag delta reads the handle's computed direction so dragging resizes intuitively in RTL.
+@nynexman4464
diff --git a/packages/core/src/Chat/ChatMessageBubble.tsx b/packages/core/src/Chat/ChatMessageBubble.tsx
index baeaa4ecd9..c397377f54 100644
--- a/packages/core/src/Chat/ChatMessageBubble.tsx
+++ b/packages/core/src/Chat/ChatMessageBubble.tsx
@@ -160,27 +160,32 @@ const styles = stylex.create({
backgroundColor: 'transparent',
color: colorVars['--color-text-primary'],
},
- // Grouped bubble corners — assistant (left side tight)
+ // Grouped bubble corners — assistant (inline-start side tight).
+ // Logical radii so the tail follows reading direction: inline-start is the
+ // left edge under LTR and the right edge under RTL (assistant tucks toward
+ // the start of the line in both directions).
groupFirstAssistant: {
- borderBottomLeftRadius: radiusVars['--radius-inner'],
+ borderEndStartRadius: radiusVars['--radius-inner'],
},
groupMiddleAssistant: {
- borderTopLeftRadius: radiusVars['--radius-inner'],
- borderBottomLeftRadius: radiusVars['--radius-inner'],
+ borderStartStartRadius: radiusVars['--radius-inner'],
+ borderEndStartRadius: radiusVars['--radius-inner'],
},
groupLastAssistant: {
- borderTopLeftRadius: radiusVars['--radius-inner'],
+ borderStartStartRadius: radiusVars['--radius-inner'],
},
- // Grouped bubble corners — user (right side tight)
+ // Grouped bubble corners — user (inline-end side tight).
+ // Logical radii: inline-end is the right edge under LTR and the left edge
+ // under RTL (user tucks toward the end of the line in both directions).
groupFirstUser: {
- borderBottomRightRadius: radiusVars['--radius-inner'],
+ borderEndEndRadius: radiusVars['--radius-inner'],
},
groupMiddleUser: {
- borderTopRightRadius: radiusVars['--radius-inner'],
- borderBottomRightRadius: radiusVars['--radius-inner'],
+ borderStartEndRadius: radiusVars['--radius-inner'],
+ borderEndEndRadius: radiusVars['--radius-inner'],
},
groupLastUser: {
- borderTopRightRadius: radiusVars['--radius-inner'],
+ borderStartEndRadius: radiusVars['--radius-inner'],
},
});
diff --git a/packages/core/src/Resizable/ResizeHandle.test.tsx b/packages/core/src/Resizable/ResizeHandle.test.tsx
index fc430156dc..096f0acda2 100644
--- a/packages/core/src/Resizable/ResizeHandle.test.tsx
+++ b/packages/core/src/Resizable/ResizeHandle.test.tsx
@@ -201,6 +201,100 @@ describe('ResizeHandle', () => {
expect(document.body.style.userSelect).toBe('');
});
+ // --- RTL pointer-drag direction ---
+
+ it('drives the region with the raw pointer delta under LTR', () => {
+ const resizable: ResizableProps = {
+ _size: 200,
+ _isCollapsed: false,
+ _onResizeStart: vi.fn(),
+ _onResizeMove: vi.fn(),
+ _onResizeEnd: vi.fn(),
+ _minSizePx: 100,
+ _maxSizePx: 400,
+ _snaps: [],
+ _collapsedSize: 40,
+ _collapsible: false,
+ _isResizableProps: true,
+ };
+ render(<ResizeHandle resizable={resizable} label="Resize" />);
+ const hitArea = screen.getByRole('separator')
+ .firstElementChild as HTMLElement;
+
+ fireEvent.pointerDown(hitArea, {clientX: 0, clientY: 0});
+ // Pointer moves +40px to the right → panel grows by +40 under LTR.
+ fireEvent.pointerMove(window, {clientX: 40, clientY: 0});
+ expect(resizable._onResizeMove).toHaveBeenLastCalledWith(40);
+ });
+
+ it('inverts the pointer delta under RTL so dragging resizes intuitively', () => {
+ const resizable: ResizableProps = {
+ _size: 200,
+ _isCollapsed: false,
+ _onResizeStart: vi.fn(),
+ _onResizeMove: vi.fn(),
+ _onResizeEnd: vi.fn(),
+ _minSizePx: 100,
+ _maxSizePx: 400,
+ _snaps: [],
+ _collapsedSize: 40,
+ _collapsible: false,
+ _isResizableProps: true,
+ };
+ // Under RTL the start panel sits on the RIGHT, so a pointer move to the
+ // right (+clientX) must SHRINK it — the delta is inverted. The handle reads
+ // its own computed `direction` via getRTLMultiplier(); jsdom doesn't resolve
+ // inherited `direction`, so force it on the separator (the handle element),
+ // mirroring the Slider RTL pointer-mapping test precedent.
+ render(<ResizeHandle resizable={resizable} label="Resize" />);
+ const separator = screen.getByRole('separator');
+ const hitArea = separator.firstElementChild as HTMLElement;
+
+ const realGetComputedStyle = window.getComputedStyle;
+ const gcsSpy = vi
+ .spyOn(window, 'getComputedStyle')
+ .mockImplementation((el: Element, pseudo?: string | null) => {
+ if (el === separator) {
+ return {direction: 'rtl'} as CSSStyleDeclaration;
+ }
+ return realGetComputedStyle(el, pseudo ?? undefined);
+ });
+
+ fireEvent.pointerDown(hitArea, {clientX: 0, clientY: 0});
+ // Same +40px physical move as LTR, but mirrored → −40 delta under RTL.
+ fireEvent.pointerMove(window, {clientX: 40, clientY: 0});
+ expect(resizable._onResizeMove).toHaveBeenLastCalledWith(-40);
+
+ gcsSpy.mockRestore();
+ });
+
+ // --- Hit-area geometry (grab zone tracks the visible pill) ---
+
+ it('anchors the biased grab zone with the pill offset and a dir-flipped centering shift', () => {
+ // For an off-center pill the hit area must reuse the pill's physical offset
+ // construction (anchored at insetInlineStart:0) rather than a divider-
+ // relative 50% anchor + percentage bias, so the two stay aligned in LTR and
+ // RTL. The half-width-difference centering shift (6.5px) is inline, so it
+ // flips physical sign under RTL: `- 6.5px` (LTR) vs `+ 6.5px` (RTL). See the
+ // Playwright measurement (hitArea.center === pill.center, 0px offset in both
+ // directions) for the geometric proof; here we lock the transform shape.
+ render(<Harness handleProps={{pillPlacement: 'start'}} />);
+ const hitArea = getSeparator().firstElementChild as HTMLElement;
+ expect(hitArea.className).toContain('hitAreaOffsetX');
+ const style = hitArea.getAttribute('style') ?? '';
+ // LTR (default) branch subtracts the centering shift; RTL branch adds it.
+ expect(style).toContain('- 6.5px');
+ expect(style).toContain('+ 6.5px');
+ });
+
+ it('centers the grab zone on the divider when the pill is centered (no bias)', () => {
+ render(<Harness handleProps={{pillPlacement: 'center'}} />);
+ const hitArea = getSeparator().firstElementChild as HTMLElement;
+ // No physical offset — a plain logical centering class, no biased transform.
+ expect(hitArea.className).toContain('hitAreaCenteredX');
+ expect(hitArea.className).not.toContain('hitAreaOffsetX');
+ });
+
// --- Prop composition (ordering choice: handler sits after {...props}) ---
it('runs a consumer onKeyDown alongside keyboard resizing', () => {
diff --git a/packages/core/src/Resizable/ResizeHandle.tsx b/packages/core/src/Resizable/ResizeHandle.tsx
index acd11f08a8..c279f37e91 100644
--- a/packages/core/src/Resizable/ResizeHandle.tsx
+++ b/packages/core/src/Resizable/ResizeHandle.tsx
@@ -56,14 +56,27 @@ function resolveEffectiveSide(
}
/**
- * Hit area bias percentage. When the pill is off-center, the grab zone
- * shifts ~2:1 toward the pill so users can reach the visible grip easily.
+ * Hit-area inline bias, expressed as a fraction of the pill's per-side offset.
+ *
+ * The visible pill is placed by `pillOffsetX`/`pillOffsetY`: anchored at the
+ * divider's inline-start edge and pushed one grip-width-plus-gap toward the
+ * panel side via a PHYSICAL translate (dir −1 = start, +1 = end). Because that
+ * offset is physical, the pill sits on the same physical side of the divider in
+ * both LTR and RTL. The grab zone must sit OVER that pill, so it has to use the
+ * exact same anchor + physical-offset construction as the pill (just wider) —
+ * anchoring the hit area at the divider centre (`insetInlineStart: 50%`) and
+ * biasing with a percentage translate mixes a logical anchor (which flips under
+ * RTL) with a physical translate (which doesn't), leaving the grab zone stranded
+ * to one side under RTL. Returning the pill's `dir` here lets the hit area reuse
+ * `pillOffsetX`/`pillOffsetY` so the two elements are positioned identically.
*/
-function hitAreaBias(effectiveSide: 'start' | 'end' | 'center'): string {
+function hitAreaBiasDir(
+ effectiveSide: 'start' | 'end' | 'center',
+): number | null {
if (effectiveSide === 'center') {
- return '50%';
+ return null;
}
- return effectiveSide === 'start' ? '66.67%' : '33.33%';
+ return effectiveSide === 'start' ? -1 : 1;
}
const styles = stylex.create({
@@ -102,8 +115,8 @@ const styles = stylex.create({
},
overlayVertical: {
insetBlockEnd: 0,
- left: 0,
- right: 0,
+ insetInlineStart: 0,
+ insetInlineEnd: 0,
height: 'var(--resize-handle-hit-area, 16px)',
},
horizontal: {
@@ -145,16 +158,24 @@ const styles = stylex.create({
width: spacingVars['--spacing-4'],
top: 0,
bottom: 0,
- left: '50%',
cursor: 'col-resize',
},
hitAreaVertical: {
height: spacingVars['--spacing-4'],
- left: 0,
- right: 0,
- top: '50%',
+ insetInlineStart: 0,
+ insetInlineEnd: 0,
cursor: 'row-resize',
},
+ // Centered grab zone (pillPlacement 'center' / no bias): sit the hit area on
+ // the divider itself. Anchored logically so it centers in both directions.
+ hitAreaCenteredX: {
+ insetInlineStart: '50%',
+ transform: 'translateX(-50%)',
+ },
+ hitAreaCenteredY: {
+ insetBlockStart: '50%',
+ transform: 'translateY(-50%)',
+ },
// Pill base — themes target .astryx-resize-handle-pill for size/shape.
pill: {
@@ -167,7 +188,7 @@ const styles = stylex.create({
transitionDuration: durationVars['--duration-fast'],
transitionTimingFunction: easeVars['--ease-standard'],
top: '50%',
- left: '50%',
+ insetInlineStart: '50%',
transform: 'translate(-50%, -50%)',
},
pillHorizontal: {
@@ -193,14 +214,32 @@ const styles = stylex.create({
// Dynamic styles — avoids inline style overrides.
// Each axis gets its own function since StyleX requires static structure.
const dynamicStyles = stylex.create({
- hitAreaBiasX: (pct: string) => ({
- transform: `translateX(-${pct})`,
+ // Hit-area inline offset — mirrors the pill's `pillOffsetX`/`pillOffsetY`
+ // construction so the grab zone sits centred on the visible pill in BOTH
+ // directions. Both anchor at the divider's inline-start edge
+ // (`insetInlineStart: 0`) and travel toward the panel side with the SAME
+ // physical translate `dir * (gripWidth + gap)`, so they share the pill's
+ // near edge. The hit area is wider, so it also shifts by half the width
+ // difference `(16px − 3px) / 2 = 6.5px` to align the two CENTRES. That
+ // centring shift is along the inline axis (a box grows from its inline-start
+ // edge toward inline-end), so it must flip physical sign under RTL — unlike
+ // the `dir * (...)` travel, which is physical and identical in both
+ // directions because the pill's own offset is physical. Mixing the previous
+ // divider-relative `50%` anchor with a percentage translate stranded the grab
+ // zone to one side under RTL; this construction keeps it on the pill.
+ hitAreaOffsetX: (dir: number) => ({
+ insetInlineStart: 0,
+ transform: {
+ default: `translate(calc(${dir} * (3px + ${spacingVars['--spacing-1']}) - 6.5px), -50%)`,
+ ':is([dir="rtl"] *)': `translate(calc(${dir} * (3px + ${spacingVars['--spacing-1']}) + 6.5px), -50%)`,
+ },
}),
- hitAreaBiasY: (pct: string) => ({
- transform: `translateY(-${pct})`,
+ hitAreaOffsetY: (dir: number) => ({
+ insetBlockStart: 0,
+ transform: `translate(-50%, calc(${dir} * (3px + ${spacingVars['--spacing-1']}) - 6.5px))`,
}),
pillOffsetX: (dir: number) => ({
- left: 0,
+ insetInlineStart: 0,
transform: `translate(calc(${dir} * (100% + ${spacingVars['--spacing-1']})), -50%)`,
}),
// Vertical offset: no rotation — use explicit landscape dimensions.
@@ -333,6 +372,9 @@ export function ResizeHandle({
isReversed,
resizable?._isCollapsed ?? false,
);
+ // Physical offset direction shared by the pill and the grab zone (null =
+ // centered / no bias). Keeps the two positioned identically in LTR and RTL.
+ const hitBiasDir = hitAreaBiasDir(effectiveSide);
const getRTLMultiplier = useCallback((): number => {
const el = handleRef.current;
@@ -538,9 +580,17 @@ export function ResizeHandle({
{...stylex.props(
styles.hitArea,
isHorizontal ? styles.hitAreaHorizontal : styles.hitAreaVertical,
- isHorizontal
- ? dynamicStyles.hitAreaBiasX(hitAreaBias(effectiveSide))
- : dynamicStyles.hitAreaBiasY(hitAreaBias(effectiveSide)),
+ // Bias the grab zone to sit over the visible pill. When the pill is
+ // centered (no bias) just center the hit area on the divider; when
+ // it's offset to a panel side, reuse the pill's physical-offset
+ // construction so the two stay aligned in LTR and RTL alike.
+ hitBiasDir == null
+ ? isHorizontal
+ ? styles.hitAreaCenteredX
+ : styles.hitAreaCenteredY
+ : isHorizontal
+ ? dynamicStyles.hitAreaOffsetX(hitBiasDir)
+ : dynamicStyles.hitAreaOffsetY(hitBiasDir),
isDisabled && styles.disabled,
)}
onPointerDown={handlePointerDown}
diff --git a/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx b/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx
index da4b220eb2..d3caf7fcb0 100644
--- a/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx
+++ b/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx
@@ -213,7 +213,12 @@ const SHADOW_WIDTH = '6px';
// --color-shadow is only ~10% alpha (too faint here); use a slightly stronger soft tint.
const SHADOW_TINT = 'light-dark(rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.32))';
const shadowStyles = stylex.create({
- // start-pinned: shadow falls to the right (inline-end), over scrolled content
+ // start-pinned: shadow falls toward inline-end (over scrolled content).
+ // insetInlineEnd anchors the strip to the column's inline-end edge; the strip
+ // must then be nudged one full width OUTWARD (past that edge) into the
+ // scrolled region. Outward is +X under LTR (inline-end = right) but −X under
+ // RTL (inline-end = left), and the fade must run from the pinned edge toward
+ // content in each direction — hence both transform and gradient flip on dir.
start: {
'::after': {
content: '""',
@@ -222,14 +227,24 @@ const shadowStyles = stylex.create({
bottom: 0,
insetInlineEnd: 0,
width: SHADOW_WIDTH,
- transform: 'translateX(100%)',
+ transform: {
+ default: 'translateX(100%)',
+ ':is([dir="rtl"] *)': 'translateX(-100%)',
+ },
pointerEvents: 'none',
transition: 'opacity 150ms ease',
opacity: `var(${SHADOW_VAR_START}, 0)`,
- backgroundImage: `linear-gradient(to right, ${SHADOW_TINT}, transparent)`,
+ backgroundImage: {
+ default: `linear-gradient(to right, ${SHADOW_TINT}, transparent)`,
+ ':is([dir="rtl"] *)': `linear-gradient(to left, ${SHADOW_TINT}, transparent)`,
+ },
},
},
- // end-pinned: shadow falls to the left (inline-start), over scrolled content
+ // end-pinned: shadow falls toward inline-start (over scrolled content).
+ // insetInlineStart anchors the strip to the column's inline-start edge; the
+ // strip is nudged one full width OUTWARD into content — −X under LTR
+ // (inline-start = left) but +X under RTL (inline-start = right) — with the
+ // gradient fading from the pinned edge toward content in each direction.
end: {
'::after': {
content: '""',
@@ -238,11 +253,17 @@ const shadowStyles = stylex.create({
bottom: 0,
insetInlineStart: 0,
width: SHADOW_WIDTH,
- transform: 'translateX(-100%)',
+ transform: {
+ default: 'translateX(-100%)',
+ ':is([dir="rtl"] *)': 'translateX(100%)',
+ },
pointerEvents: 'none',
transition: 'opacity 150ms ease',
opacity: `var(${SHADOW_VAR_END}, 0)`,
- backgroundImage: `linear-gradient(to left, ${SHADOW_TINT}, transparent)`,
+ backgroundImage: {
+ default: `linear-gradient(to left, ${SHADOW_TINT}, transparent)`,
+ ':is([dir="rtl"] *)': `linear-gradient(to right, ${SHADOW_TINT}, transparent)`,
+ },
},
},
});
@@ -289,16 +310,24 @@ export function useTableStickyColumns<T extends Record<string, unknown>>(
const {hasStart: hs, hasEnd: he} = stateRef.current;
const maxScroll = el.scrollWidth - el.clientWidth;
const hasOverflow = maxScroll > 1;
+ // RTL-safe scroll position. Spec-compliant browsers report a NEGATIVE
+ // scrollLeft under RTL (0 at the inline-start edge, decreasing toward the
+ // inline-end edge), so a raw `scrollLeft > 1` start test would never fire
+ // and the end test would be wrong-signed. Math.abs collapses both
+ // conventions to a distance-from-inline-start, matching the repo's own
+ // useScrollOverflow (overflowStart/overflowEnd use Math.abs, tolerance 1).
+ // No-op under LTR where scrollLeft is already >= 0.
+ const pos = Math.abs(el.scrollLeft);
if (hs) {
el.style.setProperty(
SHADOW_VAR_START,
- hasOverflow && el.scrollLeft > 1 ? '1' : '0',
+ hasOverflow && pos > 1 ? '1' : '0',
);
}
if (he) {
el.style.setProperty(
SHADOW_VAR_END,
- hasOverflow && el.scrollLeft < maxScroll - 1 ? '1' : '0',
+ hasOverflow && pos < maxScroll - 1 ? '1' : '0',
);
}
};