An open source design system that's fully customizable and agent ready
TypeScript
fix(core): keep the ResizeHandle grab zone on the handle (#5198)
Cindy Zhang3ed227e9bec2
diff --git a/.changeset/resize-handle-grab-zone-cross-axis.md b/.changeset/resize-handle-grab-zone-cross-axis.mdnew file mode 100644index 0000000000..769cf86a4c--- /dev/null+++ b/.changeset/resize-handle-grab-zone-cross-axis.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] ResizeHandle: dragging the lower half of a tall handle works again. The invisible grab zone is stretched along the handle, but the offset that biases it onto the pill also carried the pill's own `-50%` centering shift — so the zone slid half the handle's length off the divider. On a full-height panel at 1440x900 the 16x900 hit box sat at y=-434, leaving everything below the pill's centre dead: a pointerdown on the visible grip's centre, or anywhere lower, started no drag at all. The dead region grew with the panel, and the same shift stranded the grab zone sideways on vertical handles. The bias now moves the zone along the pill's axis only.++@cixzhangdiff --git a/packages/core/src/Resizable/ResizeHandle.test.tsx b/packages/core/src/Resizable/ResizeHandle.test.tsxindex 30d69b7817..938a446742 100644--- a/packages/core/src/Resizable/ResizeHandle.test.tsx+++ b/packages/core/src/Resizable/ResizeHandle.test.tsx@@ -344,6 +344,28 @@ describe('ResizeHandle', () => {expect(hitArea.className).not.toContain('hitAreaOffsetX');});+ // The grab zone is stretched along the handle by its 0/0 insets, so anything+ // that moves it across the handle displaces the whole zone off the divider —+ // a percentage does it by half the handle's length, so the taller the panel+ // the larger the dead region, and nothing about it is visible on screen.+ it.each([+ ['horizontal' as const, 'translateX'],+ ['vertical' as const, 'translateY'],+ ])('offsets the %s grab zone along the pill axis only', (direction, axis) => {+ render(<Harness handleProps={{direction, pillPlacement: 'start'}} />);+ const hitArea = getSeparator().firstElementChild as HTMLElement;+ const translates = (hitArea.getAttribute('style') ?? '')+ .split(';')+ .map(decl => decl.split(/:(.*)/s)[1]?.trim() ?? '')+ .filter(value => value.startsWith('translate'));++ // Both the LTR and RTL declarations of the horizontal offset.+ expect(translates.length).toBeGreaterThan(0);+ for (const translate of translates) {+ expect(translate.startsWith(`${axis}(`)).toBe(true);+ }+ });+// --- 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.tsxindex cf75436254..29e4d94acc 100644--- a/packages/core/src/Resizable/ResizeHandle.tsx+++ b/packages/core/src/Resizable/ResizeHandle.tsx@@ -219,16 +219,22 @@ const dynamicStyles = stylex.create({// 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.+ //+ // Only the offset axis is translated. Unlike the pill — a small box anchored+ // at the divider's midpoint, so it needs a −50% self-shift to centre — the+ // grab zone is STRETCHED along the handle by hitAreaHorizontal/Vertical's+ // 0/0 insets, so it is already in place on that axis. A percentage there+ // would displace it by half the handle's own length, growing with the panel.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%)`,+ default: `translateX(calc(${dir} * (3px + ${spacingVars['--spacing-1']}) - 6.5px))`,+ ':is([dir="rtl"] *)': `translateX(calc(${dir} * (3px + ${spacingVars['--spacing-1']}) + 6.5px))`,},}),hitAreaOffsetY: (dir: number) => ({insetBlockStart: 0,- transform: `translate(-50%, calc(${dir} * (3px + ${spacingVars['--spacing-1']}) - 6.5px))`,+ transform: `translateY(calc(${dir} * (3px + ${spacingVars['--spacing-1']}) - 6.5px))`,}),pillOffsetX: (dir: number) => ({insetInlineStart: 0,