Skip to content

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

TypeScript

fix(Table) useTableColumnResize: stop handles overhanging the table, reveal them on header hover (#6194)

Ernest6e0d7a87b2a9
diff --git a/.changeset/column-resize-coarse-pointer-keyboard.md b/.changeset/column-resize-coarse-pointer-keyboard.md
new file mode 100644
index 0000000000..21356a6a8c
--- /dev/null
+++ b/.changeset/column-resize-coarse-pointer-keyboard.md
@@ -0,0 +1,18 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Keep `useTableColumnResize` handles reachable by keyboard on touch-first devices (#6194)
+@ernestt
+
+The handles were hidden outright wherever the primary pointer is coarse. That
+removed the separator from the accessibility tree along with the pointer
+target, so a tablet with a keyboard attached lost column resize entirely —
+while the plugin's keyboard path, accessible name, and value bounds all went on
+promising it.
+
+Pointer capability now gates the reveal rather than the control. The handle
+stays rendered and focusable wherever any input can drive it, and coarse
+pointers instead get `pointer-events: none`: dragging a hairline boundary by
+finger is not a supported path, and an invisible 8px strip that swallows
+touches on the header is worse than no target at all.
diff --git a/.changeset/column-resize-hover-affordance.md b/.changeset/column-resize-hover-affordance.md
new file mode 100644
index 0000000000..bd30a96109
--- /dev/null
+++ b/.changeset/column-resize-hover-affordance.md
@@ -0,0 +1,6 @@
+---
+'@astryxdesign/core': patch
+---
+
+[feat] `useTableColumnResize` now reveals its handles when the pointer enters the header. The boundaries were only drawn once the pointer was already within a handle's 8px hit area, so a resizable column gave no sign it could be resized. Every boundary now appears at border weight while the header is hovered, and the handle under the pointer still takes accent. The reveal holds while the table is scrolling sideways, so a boundary arriving under a still pointer is not mistaken for intent, and focusing a handle emphasizes that one boundary without drawing its neighbours. Pointer-only: where nothing can hover, nothing is revealed. (#6194)
+@ernestt
diff --git a/.changeset/table-resize-handle-overshoot.md b/.changeset/table-resize-handle-overshoot.md
new file mode 100644
index 0000000000..ba9214b7d7
--- /dev/null
+++ b/.changeset/table-resize-handle-overshoot.md
@@ -0,0 +1,21 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Stop `useTableColumnResize` handles from adding stray vertical scroll (#6194)
+@ernestt
+
+The resize handles span the whole table so their indicator line reads down
+through the body rows. They were given the table's full height but hung from a
+point a few pixels below its top edge, so each one ended that far past the last
+row. The table's scroll wrapper only exists to scroll horizontally, but CSS
+promotes its `overflow-y` to `auto` as soon as `overflow-x` is, so the overhang
+turned into ~6px of vertical scrolling on a table that had no reason to scroll.
+
+The observer that measures the table now also measures how far the handles
+start below its top edge and publishes it as `--table-resize-offset`, which the
+handles subtract from their height. The drop is per-cell — a handle hangs from
+its cell's content box, and the header's vertical centring shifts that box by an
+amount that depends on how tall each header's own content is — so the largest is
+published: a handle can stop a fraction short of the last row without anyone
+noticing, but it cannot hang past it.
diff --git a/.changeset/table-sticky-resize-position-collision.md b/.changeset/table-sticky-resize-position-collision.md
new file mode 100644
index 0000000000..956aa99440
--- /dev/null
+++ b/.changeset/table-sticky-resize-position-collision.md
@@ -0,0 +1,17 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Stop column resize and sticky columns from fighting over pinned headers (#6194)
+@ernestt
+
+Both plugins style the same header cell, and both set `position` on it —
+`useTableColumnResize` needs `relative` to anchor its handle, sticky columns
+needs `sticky` to pin. Sticky set its through a StyleX class rather than inline
+as its sibling offsets already were, so the two landed in the same style array
+and the later plugin won. A pinned column silently stopped pinning depending on
+the order the caller happened to write `plugins={{ ... }}`.
+
+`useTableStickyColumns` now writes `position` inline alongside the offsets it
+was already writing there, which outranks either plugin's classes and makes the
+composition independent of plugin order rather than dependent on a lucky one.
diff --git a/packages/core/src/Table/plugins/columnResize/useTableColumnResize.test.tsx b/packages/core/src/Table/plugins/columnResize/useTableColumnResize.test.tsx
index af45525dd4..dabd82dd47 100644
--- a/packages/core/src/Table/plugins/columnResize/useTableColumnResize.test.tsx
+++ b/packages/core/src/Table/plugins/columnResize/useTableColumnResize.test.tsx
@@ -786,4 +786,134 @@ describe('useTableColumnResize', () => {
expect(handles).toHaveLength(2);
});
});
+
+ // ===========================================================================
+ // Disclosure — scroll gate (FR10), focus scope (FR9)
+ // ===========================================================================
+
+ describe('disclosure', () => {
+ /**
+ * The gate lives on the scroll wrapper as an inline custom property that
+ * the header row and handles inherit. Asserting the property directly is
+ * the only honest check in JSDOM: the reveal itself is a CSS media/hover
+ * resolution that no JSDOM computed style will report.
+ */
+ function getScrollWrapper(container: HTMLElement): HTMLElement {
+ const table = container.querySelector('table');
+ const wrapper = table?.closest('div[class]');
+ if (!wrapper) {
+ throw new Error('scroll wrapper not found');
+ }
+ return wrapper as HTMLElement;
+ }
+
+ it('closes the disclosure gate while the region scrolls', () => {
+ const {container} = render(<ResizeTable columns={pixelColumns} />);
+ const wrapper = getScrollWrapper(container);
+
+ expect(wrapper.style.getPropertyValue('--resize-hint-gate')).toBe('');
+
+ fireEvent.scroll(wrapper);
+
+ expect(wrapper.style.getPropertyValue('--resize-hint-gate')).toBe(
+ 'transparent',
+ );
+ });
+
+ it('reopens the gate once scrolling settles', () => {
+ const {container} = render(<ResizeTable columns={pixelColumns} />);
+ const wrapper = getScrollWrapper(container);
+
+ fireEvent.scroll(wrapper);
+ expect(wrapper.style.getPropertyValue('--resize-hint-gate')).toBe(
+ 'transparent',
+ );
+
+ fireEvent(wrapper, new Event('scrollend'));
+
+ expect(wrapper.style.getPropertyValue('--resize-hint-gate')).toBe('');
+ });
+
+ it('falls back to a settle timeout where scrollend is unsupported', () => {
+ vi.useFakeTimers();
+ // Force the fallback path: the gate probes for `onscrollend` when the
+ // ref attaches, so the property has to be gone before the first render.
+ // Take the descriptor rather than reading the value — the accessor is a
+ // real getter and throws when invoked on the prototype itself.
+ const proto = window.HTMLElement.prototype;
+ const descriptor = Object.getOwnPropertyDescriptor(proto, 'onscrollend');
+ if (descriptor) {
+ // @ts-expect-error — deleting a DOM accessor for the duration of one test
+ delete proto.onscrollend;
+ }
+
+ try {
+ const {container} = render(<ResizeTable columns={pixelColumns} />);
+ const wrapper = getScrollWrapper(container);
+
+ fireEvent.scroll(wrapper);
+ expect(wrapper.style.getPropertyValue('--resize-hint-gate')).toBe(
+ 'transparent',
+ );
+
+ // Still closed part-way through the settle window.
+ vi.advanceTimersByTime(60);
+ expect(wrapper.style.getPropertyValue('--resize-hint-gate')).toBe(
+ 'transparent',
+ );
+
+ vi.advanceTimersByTime(120);
+ expect(wrapper.style.getPropertyValue('--resize-hint-gate')).toBe('');
+ } finally {
+ if (descriptor) {
+ Object.defineProperty(proto, 'onscrollend', descriptor);
+ }
+ vi.useRealTimers();
+ }
+ });
+
+ it('scrolling does not rerender the Table', () => {
+ const renderSpy = vi.fn();
+
+ function CountingResizeTable() {
+ renderSpy();
+ const resizePlugin = useTableColumnResize<TestItem>({
+ columns: pixelColumns as TableColumn<Record<string, unknown>>[],
+ });
+ return (
+ <Table
+ data={testData}
+ columns={pixelColumns}
+ idKey="id"
+ plugins={{resize: resizePlugin}}
+ />
+ );
+ }
+
+ const {container} = render(<CountingResizeTable />);
+ const wrapper = getScrollWrapper(container);
+ const before = renderSpy.mock.calls.length;
+
+ fireEvent.scroll(wrapper);
+ fireEvent.scroll(wrapper);
+ fireEvent(wrapper, new Event('scrollend'));
+
+ expect(renderSpy.mock.calls.length).toBe(before);
+ });
+
+ it('focusing a handle leaves the gate and the row hint alone', () => {
+ const {container} = render(<ResizeTable columns={pixelColumns} />);
+ const wrapper = getScrollWrapper(container);
+ const [first] = getResizeHandles();
+
+ first.focus();
+ expect(first).toHaveFocus();
+
+ // Focus is deliberate: it must not trip the scroll gate, and it must not
+ // publish a row-level hint — only the focused boundary is emphasized.
+ expect(wrapper.style.getPropertyValue('--resize-hint-gate')).toBe('');
+ const headerRow = container.querySelector('thead tr') as HTMLElement;
+ expect(headerRow.style.getPropertyValue('--resize-hint')).toBe('');
+ });
+ });
});
diff --git a/packages/core/src/Table/plugins/columnResize/useTableColumnResize.tsx b/packages/core/src/Table/plugins/columnResize/useTableColumnResize.tsx
index ce81ddaefc..996cc039d2 100644
--- a/packages/core/src/Table/plugins/columnResize/useTableColumnResize.tsx
+++ b/packages/core/src/Table/plugins/columnResize/useTableColumnResize.tsx
@@ -19,8 +19,10 @@ import {colorVars} from '../../../theme/tokens.stylex';
import type {
TablePlugin,
HeaderCellRenderProps,
+ HeaderRowRenderProps,
TableColumn,
ColumnWidth,
+ ScrollWrapperRenderProps,
} from '../../types';
import {
DEFAULT_FLEXIBLE_COLUMN_MIN_WIDTH,
@@ -90,6 +92,13 @@ export interface UseTableColumnResizeConfig {
const FALLBACK_MIN_WIDTH = 50;
const KEYBOARD_STEP = 10;
const KEYBOARD_LARGE_STEP = 50;
+/**
+ * How long after the last scroll event the disclosure gate stays closed, where
+ * `scrollend` is unavailable. Long enough to bridge the gaps between events in
+ * a momentum scroll, short enough that a deliberate hover right after one is
+ * not left waiting.
+ */
+const SCROLL_SETTLE_MS = 120;
// =============================================================================
// Width Helpers
@@ -201,10 +210,17 @@ const handleStyles = stylex.create({
top: 0,
// Extend the handle the full height of the table, not just the header.
// The <th> has overflow:visible (from headerCellRelative), so the handle
- // visually reaches through the body rows. The CSS variable is set by
- // the plugin's ResizeObserver — falls back to 100% (header only) when
- // the observer hasn't fired yet.
- height: 'var(--table-resize-height, 100%)',
+ // visually reaches through the body rows. Both variables are set by the
+ // plugin's ResizeObserver — they fall back to header-height when it
+ // hasn't fired yet.
+ //
+ // `top: 0` does not land on the table's top edge: the handle hangs from
+ // its cell's content box, and the header's vertical centring shifts that
+ // box down by an amount that depends on how tall its own content is.
+ // Subtracting that drop keeps the handle from hanging past the last row
+ // and forcing the scroll wrapper to scroll.
+ height:
+ 'calc(var(--table-resize-height, 100%) - var(--table-resize-offset, 0px))',
// Wide transparent hit area; the visible indicator uses ::after to span
// the full handle height independently of the border box.
width: '8px',
@@ -218,14 +234,42 @@ const handleStyles = stylex.create({
// Drive the indicator color via a CSS variable that ::after reads.
// The parent handle is the hover/focus target — pseudo-elements
// can't receive :hover directly.
+ /*
+ * The resting value is inherited rather than fixed: the header row sets
+ * `--resize-hint` while it is hovered, which reveals every boundary at
+ * once so the columns can advertise that they move. Reading it as the
+ * default (instead of matching the row's hover from down here) keeps this
+ * element's own :hover a plain same-element override — an ancestor
+ * selector would outrank it and the handle under the pointer would never
+ * reach accent.
+ *
+ * The pointer arm passes through the same `--resize-hint-gate` as the row
+ * hint: horizontal scrolling drags columns under a still pointer, so a
+ * boundary arriving beneath it mid-scroll is no more intentional than the
+ * row-level reveal (FR10). Focus-visible is ungated — focus is always
+ * deliberate.
+ */
'--indicator-color': {
- default: 'transparent',
- ':hover:where(:not(:disabled,[aria-disabled="true"]))':
- colorVars['--color-accent'],
+ default: 'var(--resize-hint, transparent)',
+ ':hover:where(:not(:disabled,[aria-disabled="true"]))': `var(--resize-hint-gate, ${colorVars['--color-accent']})`,
':focus-visible': colorVars['--color-accent'],
},
+ /*
+ * Pointer capability gates the REVEAL, not the control (DEC-3). The
+ * handle stays rendered and focusable wherever any input can drive it, so
+ * a coarse-primary device with a keyboard keeps its tab stop, its
+ * accessible name, and arrow-key resize (FR6, FR8, AR6).
+ *
+ * What coarse pointers lose is pointer interaction: dragging a hairline
+ * boundary by finger is a non-goal (DEC-4), and an invisible 8px strip
+ * that swallows touches on the header is worse than no target at all.
+ * `pointer-events: none` removes it from touch without removing it from
+ * the accessibility tree the way `display: none` did. The hover reveal is
+ * already gated separately on the header row, so at rest there is nothing
+ * drawn here to explain.
+ */
'@media (pointer: coarse)': {
- display: 'none',
+ pointerEvents: 'none',
},
},
/**
@@ -251,6 +295,33 @@ const handleStyles = stylex.create({
},
});
+/**
+ * Publishes the hint colour the handles read at rest. Hover has to be caught
+ * on the row so that entering the header anywhere reveals every boundary, not
+ * only the cell under the pointer. Pointer-only — there is no hover to lead
+ * with on touch, and the handles ignore touch there regardless.
+ *
+ * `--resize-hint-gate` is the scroll gate (FR10): the scroll listener sets it
+ * to `transparent` on the scroll wrapper while the region is moving, which
+ * wins here because a set custom property beats the fallback arm of `var()`.
+ * Hover keeps resolving underneath — the gate just hides its result until the
+ * region settles, so nothing has to be recomputed when it clears.
+ *
+ * Focus is deliberately absent: focusing a boundary emphasizes that one
+ * boundary and never raises this row-level hint (FR9, DEC-5).
+ */
+const headerRowStyles = stylex.create({
+ base: {
+ '--resize-hint': {
+ default: 'transparent',
+ '@media (hover: hover)': {
+ default: 'transparent',
+ ':hover:where(:not(:disabled,[aria-disabled="true"]))': `var(--resize-hint-gate, ${colorVars['--color-border']})`,
+ },
+ },
+ },
+});
+
const headerCellRelative = stylex.create({
base: {
position: 'relative',
@@ -688,6 +759,9 @@ function ResizeHandle({
aria-valuemax={maxWidth === Infinity ? undefined : maxWidth}
aria-label={ariaLabel}
tabIndex={0}
+ // Lets the height observer find its own handles without matching any
+ // separator a consumer happens to render inside the table.
+ data-resize-handle=""
onPointerDown={handlePointerDown}
onKeyDown={handleKeyDown}
{...stylex.props(handleStyles.base, handleStyles.indicator)}
@@ -725,8 +799,9 @@ export function useTableColumnResize<T extends Record<string, unknown>>(
);
// Measure the table height via ResizeObserver and expose as
- // --table-resize-height on the <table> element. This is initialized
- // entirely by the resize plugin — the base table has no knowledge of it.
+ // --table-resize-height on the <table> element, alongside the distance the
+ // handles start below that top edge. Both are initialized entirely by the
+ // resize plugin — the base table has no knowledge of either.
const observedTableRef = useRef<HTMLTableElement | null>(null);
const unobserveTableRef = useRef<(() => void) | null>(null);
@@ -745,8 +820,29 @@ export function useTableColumnResize<T extends Record<string, unknown>>(
if (table && typeof ResizeObserver !== 'undefined') {
unobserveTableRef.current = observeResize(table, () => {
- const height = table.getBoundingClientRect().height;
- table.style.setProperty('--table-resize-height', `${height}px`);
+ const rect = table.getBoundingClientRect();
+ table.style.setProperty('--table-resize-height', `${rect.height}px`);
+
+ /*
+ * Each handle hangs from its own cell's content box, so they do not
+ * all start at the same y. Publish the largest drop: every handle then
+ * ends at or just above the table's bottom edge, where ending a
+ * fraction short is invisible but overhanging is not — it shows up as
+ * a few px of stray scrolling in the wrapper.
+ *
+ * Reading the handles here cannot feed back into this observer: they
+ * are absolutely positioned, so their height never moves the table.
+ */
+ let offset = 0;
+ for (const handle of table.querySelectorAll<HTMLElement>(
+ '[data-resize-handle]',
+ )) {
+ offset = Math.max(
+ offset,
+ handle.getBoundingClientRect().top - rect.top,
+ );
+ }
+ table.style.setProperty('--table-resize-offset', `${offset}px`);
});
observedTableRef.current = table;
}
@@ -760,6 +856,74 @@ export function useTableColumnResize<T extends Record<string, unknown>>(
};
}, []);
+ /*
+ * Scroll gate (FR10). A pointer that ends up over a header because the
+ * columns moved under it has not asked for anything, so disclosure holds
+ * while the region scrolls and resumes once it settles.
+ *
+ * This runs entirely outside React: the listener writes `--resize-hint-gate`
+ * straight onto the scroll wrapper, where it inherits down to the header row
+ * and the handles, and clears it on settle. No state, no rerender, no
+ * observer — PR1's one permitted listener, plus the `scrollend` signal that
+ * tells it when to stop.
+ *
+ * `scrollend` is the correct settle signal but is not everywhere yet, so a
+ * single shared timeout stands in where it is missing. Only one of the two
+ * paths is ever armed.
+ */
+ const gateCleanupRef = useRef<(() => void) | null>(null);
+
+ const attachScrollGate = useCallback((el: HTMLDivElement | null) => {
+ gateCleanupRef.current?.();
+ gateCleanupRef.current = null;
+ if (!el) {
+ return;
+ }
+
+ let settleTimer: ReturnType<typeof setTimeout> | null = null;
+ const supportsScrollEnd = 'onscrollend' in el;
+
+ const clear = () => {
+ el.style.removeProperty('--resize-hint-gate');
+ };
+
+ const onScroll = () => {
+ // Idempotent: setting the same value on every scroll tick costs a style
+ // recalc the scroll itself already pays for, and never a React render.
+ el.style.setProperty('--resize-hint-gate', 'transparent');
+ if (supportsScrollEnd) {
+ return;
+ }
+ if (settleTimer != null) {
+ clearTimeout(settleTimer);
+ }
+ settleTimer = setTimeout(clear, SCROLL_SETTLE_MS);
+ };
+
+ el.addEventListener('scroll', onScroll, {passive: true});
+ if (supportsScrollEnd) {
+ el.addEventListener('scrollend', clear, {passive: true});
+ }
+
+ gateCleanupRef.current = () => {
+ el.removeEventListener('scroll', onScroll);
+ if (supportsScrollEnd) {
+ el.removeEventListener('scrollend', clear);
+ }
+ if (settleTimer != null) {
+ clearTimeout(settleTimer);
+ }
+ clear();
+ };
+ }, []);
+
+ useEffect(() => {
+ return () => {
+ gateCleanupRef.current?.();
+ gateCleanupRef.current = null;
+ };
+ }, []);
+
return useMemo(
(): TablePlugin<T> => ({
transformTableContext(children) {
@@ -769,6 +933,28 @@ export function useTableColumnResize<T extends Record<string, unknown>>(
</div>
);
},
+ transformHeaderRow(props: HeaderRowRenderProps): HeaderRowRenderProps {
+ return {...props, xstyle: [...props.xstyle, headerRowStyles.base]};
+ },
+ transformScrollWrapper(
+ props: ScrollWrapperRenderProps,
+ ): ScrollWrapperRenderProps {
+ // Compose with any ref a prior plugin (e.g. sticky columns,
+ // virtualization) already set on the scroll container.
+ const existingRef = props.htmlProps.ref;
+ const mergedRef = (node: HTMLDivElement | null) => {
+ attachScrollGate(node);
+ if (typeof existingRef === 'function') {
+ existingRef(node);
+ } else if (existingRef != null) {
+ existingRef.current = node;
+ }
+ };
+ return {
+ ...props,
+ htmlProps: {...props.htmlProps, ref: mergedRef},
+ };
+ },
transformHeaderCell(
props: HeaderCellRenderProps,
column: TableColumn<T>,
@@ -865,6 +1051,13 @@ export function useTableColumnResize<T extends Record<string, unknown>>(
};
},
}),
- [columnWidths, globalMinWidth, maxWidth, resizableColumns, measureRef],
+ [
+ columnWidths,
+ globalMinWidth,
+ maxWidth,
+ resizableColumns,
+ measureRef,
+ attachScrollGate,
+ ],
);
}
diff --git a/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.test.tsx b/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.test.tsx
index ab9f70245e..eb6454ec7c 100644
--- a/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.test.tsx
+++ b/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.test.tsx
@@ -17,6 +17,7 @@ import {describe, it, expect} from 'vitest';
import {render, screen} from '@testing-library/react';
import {Table} from '../../Table';
import {useTableStickyColumns} from './useTableStickyColumns';
+import {useTableColumnResize} from '../columnResize/useTableColumnResize';
import {pixel, proportional} from '../../columnUtils';
import type {TableColumn} from '../../types';
@@ -214,4 +215,70 @@ describe('useTableStickyColumns', () => {
expect(getHeader('Team').style.insetInlineStart).toBe('');
expect(getHeader('Team').style.insetInlineEnd).toBe('');
});
+
+ /**
+ * Composition with the resize plugin. Both plugins contribute `position` to
+ * the same header cell — resize appends `relative` for its handle's
+ * containing block — so the pin has to survive either insertion order. The
+ * plugin writes `position` inline for exactly that reason, which also makes
+ * it the jsdom-visible signal.
+ */
+ describe('composition with the column-resize plugin', () => {
+ /**
+ * With the resize plugin mounted, each header cell also contains the
+ * handle's own labelled element, so the cell's accessible name is no
+ * longer just its header text. Address the cell by its column key.
+ */
+ function getHeaderCell(key: string): HTMLElement {
+ const cell = document.querySelector<HTMLElement>(
+ `th[data-column-key="${key}"]`,
+ );
+ if (!cell) {
+ throw new Error(`header cell not found: ${key}`);
+ }
+ return cell;
+ }
+
+ function StickyResizeHarness({
+ resizeFirst,
+ }: {
+ resizeFirst: boolean;
+ }): React.ReactElement {
+ const sticky = useTableStickyColumns<Row>({startKeys: ['name']});
+ const resize = useTableColumnResize<Row>({
+ columns: columns as TableColumn<Record<string, unknown>>[],
+ });
+ return (
+ <Table
+ data={data}
+ columns={columns}
+ idKey="id"
+ plugins={
+ resizeFirst
+ ? {resize, stickyColumns: sticky}
+ : {stickyColumns: sticky, resize}
+ }
+ />
+ );
+ }
+
+ it('keeps a pinned column sticky with resize declared first', () => {
+ render(<StickyResizeHarness resizeFirst={true} />);
+ expect(getHeaderCell('name').style.position).toBe('sticky');
+ expect(getHeaderCell('name').style.insetInlineStart).toBe('0px');
+ });
+
+ it('keeps a pinned column sticky with sticky declared first', () => {
+ render(<StickyResizeHarness resizeFirst={false} />);
+ expect(getHeaderCell('name').style.position).toBe('sticky');
+ expect(getHeaderCell('name').style.insetInlineStart).toBe('0px');
+ });
+
+ it('leaves unpinned columns to the resize plugin', () => {
+ render(<StickyResizeHarness resizeFirst={true} />);
+ // Only pinned cells get an inline position; the rest keep whatever the
+ // resize plugin's own styles give them.
+ expect(getHeaderCell('team').style.position).toBe('');
+ });
+ });
});
diff --git a/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx b/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx
index dc4e56e919..9b900de6e0 100644
--- a/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx
+++ b/packages/core/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx
@@ -344,10 +344,19 @@ export function useTableStickyColumns<T extends Record<string, unknown>>(
// position/inline-offset are runtime values → set via inline style so
// they are authoritative regardless of plugin composition order (the
// resize plugin also writes inline style on header cells).
+ //
+ // `position` belongs inline for the same reason, and used not to be:
+ // it was left to `stickyStyles.cell`, which put it in the same xstyle
+ // array the resize plugin appends `position: relative` to for its
+ // handle's containing block. Whichever plugin was appended later won,
+ // so a pinned column silently stopped pinning depending on the order
+ // the caller happened to write `plugins={{ ... }}`. Inline wins over
+ // both, which makes the composition order-independent instead of
+ // buying a lucky order from the plugin sequence.
const offsetStyle: CSSProperties =
side.edge === 'start'
- ? {insetInlineStart: `${side.offset}px`}
- : {insetInlineEnd: `${side.offset}px`};
+ ? {position: 'sticky', insetInlineStart: `${side.offset}px`}
+ : {position: 'sticky', insetInlineEnd: `${side.offset}px`};
return {
...props,
htmlProps: {
diff --git a/packages/core/src/theme/derivedVarRegistry.test.ts b/packages/core/src/theme/derivedVarRegistry.test.ts
index c55ed55f6e..e32887cc56 100644
--- a/packages/core/src/theme/derivedVarRegistry.test.ts
+++ b/packages/core/src/theme/derivedVarRegistry.test.ts
@@ -81,6 +81,7 @@ const STRUCTURAL_VARS = new Set([
'--indicator-color',
'--indicator-width',
'--table-resize-height',
+ '--table-resize-offset',
// sticky-columns plugin: opaque backdrop (overridable) + the row overlay it
// replays on pinned cells. Structural/runtime, not themeable design tokens.
'--table-sticky-background',