Skip to content

fix(Table, ContextMenu): a sortable column's resize line sits on its column edge - #11576

Merged
cixzhang merged 3 commits into
mainfrom
lane4/table-resize-handle-edge
Nov 13, 2026
Merged

cixzhang merged 3 commits into
mainfrom
lane4/table-resize-handle-edge

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

User impact

In a Table whose columns both sort and resize, a sortable column's resize line sat one cell padding inside the column: about 12 px at the default density, 8 px compact, 16 px spacious. Plain columns' lines sat on the divider. A person dragging the column edge found the line, and its drag target, away from the edge they could see, and a table that mixes both kinds of column showed lines at two different offsets. Now every resize line sits on its column divider, in left-to-right and right-to-left layouts. A sortable header's right-click menu still opens at the pointer.

Problem and solution fit

  1. Why it occurs. The sortable plugin gives the header a context menu, and TableHeaderCell wraps the header's content in the menu's trigger. That trigger is position: relative so it can hold the menu's cursor anchor. The resize boundary renders inside the header content and is absolutely positioned with inset-inline-end: 0, so the trigger, not the header cell, becomes its containing block, and the trigger sits inside the cell's padding.
  2. Fix. Inside a Table, the header's trigger stays unpositioned and the header cell is positioned, so the cell holds both the resize boundary and the cursor anchor. ContextMenu now measures the cursor anchor's offsets from the anchor's containing block, which is still the trigger for every other ContextMenu. A plugin's own position on the cell, such as a sticky column, still wins.

Expected behavior and authority

  • module:Table/useTableColumnResize FR1: each resizable column receives one boundary control at its trailing inline edge.
  • component:ContextMenu: the menu opens at the pointer; unchanged.

Smallest restoration

  • packages/core/src/Table/TableHeaderCell.tsx: an unpositioned trigger and a positioned cell when the header has a context menu inside a Table.
  • packages/core/src/ContextMenu/ContextMenu.tsx: the cursor anchor's offsets come from its containing block, and a keyboard open still anchors at the trigger's bottom-left.
  • A WithSortableColumns story for Core/TableColumnResize, and a [fix] changeset for @astryxdesign/core.

Evidence

Real Chromium, the Core/TableColumnResize "With sortable columns" story, desktop left-to-right, the pointer on the header row so the resize lines show. Top: the test commit alone, where Name's resize line sits 11.5 px inside its divider. Bottom: this head, where it sits on the divider. Email, a plain column, is on its divider in both.

Before and after: the Name column's resize line sits 11.5 px inside its divider, then on it

Right-to-left at desktop width, and left-to-right at a 390 px phone width, before and after. In both, Name's line moves from 11.5 px inside its divider to 0.5 px; Email is 0.5 px throughout.

Before and after, right-to-left at desktop width and left-to-right at 390 px: the Name column's resize line moves from inside its divider onto it

Every density, in both directions and at 390 px

Before, Name's line sits inside its divider by the cell's inline padding minus 0.5 px: 11.5 px (balanced), 7.5 px (compact) and 15.5 px (spacious), in left-to-right, right-to-left and at 390 px. After, it sits 0.5 px from the divider everywhere. Email, a plain column, is 0.5 px in both builds. For this capture only, the story wrapper passed density to the Table in both builds; product code is unchanged.

Before and after at balanced, compact and spacious density, each in left-to-right and right-to-left at desktop width and left-to-right at 390 px

  • Red, then green. Table/__tests__/TableColumnResizeEdge.a11y.chromium.spec.ts at the test commit alone (main plus the story and the spec): the left-to-right and right-to-left edge tests fail ("Name boundary offset from its column edge: expected at most 1, received 11.5"; Email 0.5 px), and the right-click test passes. At this head all three pass (Name and Email both 0.5 px, in both directions).
  • No change outside a Table. ContextMenu/__tests__/ContextMenuCursorAnchor.a11y.browser.spec.ts (a right-click in a scroll container paints at the pointer; the anchor hides and returns on scroll; a keyboard open on the bottom edge) passes all 3 at main and at this head.
  • The ContextMenu and Table unit suites pass (49 files, 962 tests), with no type errors and eslint clean.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm exec vitest run packages/core/src/ContextMenu packages/core/src/Table: 49 files, 962 tests pass.
  • tsc --noEmit for @astryxdesign/core: clean.
  • The Chromium check runs in CI's accessibility legs (its @pr-a11y scope covers Table, ContextMenu and the story).

Fixes #11560. Thanks to @mohamedhassank20 for the precise report and the suggested fix.

Owner: fix-loop lane 4. Land path: Drain merges after CodeBunny, Specs, CI and the cx-8201 exemption at its head.

A story mixes sortable and plain resizable columns. A Chromium check
reads every boundary's trailing edge against its header cell's, in both
directions, and that a sortable header's menu opens at the pointer.
…its column edge

The header's context-menu wrapper was positioned, so it held the resize
boundary one cell padding inside the column. Inside a Table the wrapper
stays unpositioned and the cell holds the boundary and the menu's cursor
anchor. ContextMenu measures the anchor's offsets from its containing
block, which is the trigger unless the trigger is left unpositioned.

Fixes #11560
@vercel

vercel Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 13, 2026 9:06pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 13, 2026
@astracat-bot

astracat-bot Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 13, 2026, 10:34 PM UTC

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 13, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 0e822bd

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 5b78a3c

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
TableBody 3.5 kB (0) · 3.3 kB CSS (0) — ✓ · ✓ · ✗
TableFooter 3.5 kB (0) · 3.3 kB CSS (0) — ✓ · ✓ · ✗
TableHeader 3.5 kB (0) · 3.3 kB CSS (0) — ✓ · ✓ · ✗
9 more components
Component Size LoC Visual · A11y · RTL
TableRow 7.1 kB (0) · 4.0 kB CSS (0) — ✓ · ✓ · ✗
Table 135.7 kB (+115 B) · 19.2 kB CSS (+11 B) — ✓ · ✓ · —
lab/CommentThread 360.6 kB (+124 B) · 2.4 kB CSS (0) — — · — · —
TableHeaderCell 118.4 kB (+111 B) · 18.6 kB CSS (+11 B) — ✓ · ✓ · ✓
lab/Comments 367.4 kB (+114 B) · 2.5 kB CSS (0) — — · — · —
Markdown 198.6 kB (+107 B) · 21.5 kB CSS (0) — — · — · —
TableCell 118.8 kB (+65 B) · 18.8 kB CSS (0) — ✓ · ✓ · ✓
ContextMenu · Storybook 117.6 kB (+58 B) · 18.3 kB CSS (0) 724 (+9) ✓ · ✓ · ✓
TableSelectionToolbar 75.1 kB (0) · 14.0 kB CSS (0) — ✓ · ✓ · ✓

Package size: @astryxdesign/core 7.52 MB packed (+1.0 kB); no new dependencies.

Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot 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.

Requesting changes: this puts the resize line back on the column divider for sortable columns in both directions (11.5 px inside on the base code, 0.5 px on this head in Chromium), and two small fixes are needed first.

  • TableHeaderCell.tsx:153-155 copies hasContextMenu from TableCell.tsx:222-224, and both re-decide what wrapInTableContextMenu decides, so if the cell flag and the wrapper drift apart the trigger stays positioned and the line moves back inside the column; export one predicate from tableContextMenu.tsx and call it from all three.
  • The Evidence section says the real-browser run is attached below, but nothing is attached and CI has not run on this draft; drop that clause or state the run's result in text.

Non-blocking: the menu still opens 0.5 px off the pointer on cells with a leading divider (Role in left-to-right, Name in right-to-left), and subtracting clientLeft would over-correct, because those cells report 1 for the 0.5 px collapsed half-divider; taking the origin from the anchor's own rect minus its current left and top keeps it on the pointer.

Claims and files checked
  • Claim: a sortable column's resize line sat one cell padding inside the column (about 12, 8 and 16 px by density). Verified: 11.5 px measured at the default density, whose inline padding is 12 px; the compact and spacious paddings are 8 and 16 px.
  • Claim: plain columns' lines sat on the divider. Verified: 0.5 px on the base code.
  • Claim: the drag target sat away from the visible edge, and mixed tables showed two offsets. Verified: the 8 px strip moves with the line.
  • Claim: every resize line now sits on its divider, left-to-right and right-to-left. Verified: 0.5 px for every boundary on this head.
  • Claim: a sortable header's right-click menu still opens at the pointer. Verified within 0.5 px (see the non-blocking note).
  • Claim: the positioned context-menu trigger, not the cell, contains the absolutely positioned boundary. Verified in code and in the browser (the trigger is position: relative on the base).
  • Claim: inside a Table the trigger stays unpositioned and the cell is positioned; ContextMenu measures from the anchor's containing block, still the trigger elsewhere; a plugin's own position wins. Verified (TableHeaderCell.tsx:94-107, :169-182, ContextMenu.tsx:618-625; sticky columns set their position after the cell styles).
  • Claim: a keyboard open still anchors at the trigger's bottom-left. Verified (1 px lower than before).
  • Claim: the governing claims are the resize module's trailing-edge boundary and ContextMenu's pointer anchor. Verified.
  • Claim: the smallest restoration is two source files, a story and a changeset. Verified; the new spec is listed under Evidence.
  • Claim: the new Chromium spec checks every boundary within 1 px in both directions and the menu anchor at the pointer, failing before the fix and passing with it. Verified: both boundary tests fail on the base code (11.5 px) and all 3 pass on this head.
  • Claim: the real-browser run is attached below. False: nothing is attached.
  • Claim: the ContextMenu and Table unit suites pass (49 files, 962 tests), with no type errors and clean lint. Verified.
  • Claim: the Chromium check runs in CI's accessibility legs through its scope line. Verified: the scope line is valid and matches the changed paths; CI has not run on this draft.
  • Claim: one defect, no tagalongs, no public API or presentation hidden under the fix, no internal context. Verified: the API generator lists no change.
  • Claim: fixes the linked issue. Verified.
  • Changeset: a Core patch fix with the same description and a credit line. Verified.
  • File .changeset/table-resize-handle-sortable-edge.md: clear.
  • File apps/storybook/stories/TableColumnResize.stories.tsx: clear.
  • File packages/core/src/ContextMenu/ContextMenu.tsx: non-blocking 0.5 px anchor offset; one passive comment.
  • File packages/core/src/Table/TableHeaderCell.tsx: blocking, copied hasContextMenu predicate; one long comment sentence.
  • File packages/core/src/Table/__tests__/TableColumnResizeEdge.a11y.chromium.spec.ts: clear; its menu check covers only the first column in left-to-right.

Automated review (maintainer link)

const base = cursorAnchorRef.current?.offsetParent;
return (
base instanceof HTMLElement ? base : triggerRef.current
)?.getBoundingClientRect();

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.

Non-blocking: this is the base's border box, but the anchor's left and top apply from its padding edge. On a header cell with a leading border the menu opens 0.5 px off the pointer (Role in left-to-right: anchor x 516.5 for a pointer at 516; Name in right-to-left: 1164.5 for 1164). Subtracting base.clientLeft and base.clientTop from the offsets keeps the anchor on the pointer.

cixzhang added a commit that referenced this pull request Nov 13, 2026
cixzhang added a commit that referenced this pull request Nov 13, 2026
cixzhang added a commit that referenced this pull request Nov 13, 2026
hasTableContextActions in tableContextMenu.tsx replaces the copies in
TableHeaderCell and TableCell, and wrapInTableContextMenu uses it too, so
the trigger's styling and the wrapping always agree.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 5b78a3c

@astracat-bot astracat-bot Bot 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.

Approved pending CI: one test shard was still running on this head when this review finished.

Every resize line in a Table with sortable columns now sits on its column divider in both directions: the sortable column's line moves from 11.5 px inside to 0.5 px in Chromium, matching plain columns, and the new browser spec fails before the fix and passes with it. Nothing blocks.

Non-blocking:

  • On header cells with a leading divider (Role in left-to-right, Name in right-to-left) the menu opens 0.5 px off the pointer, because the anchor's offsets come from the cell's border box while left and top apply from its padding edge; taking the origin from the anchor's own rect minus its current left and top keeps it on the pointer.
  • Two new comments could be tighter: the last sentence of TableHeaderCell.tsx:176-178 runs 26 words, and ContextMenu.tsx:618 is passive.
Claims and files checked
  • Claim: a sortable column's resize line sat one cell padding inside the column (about 12, 8 and 16 px by density). Verified: 11.5 px measured at the default density; the densities pad 12, 8 and 16 px inline, less the 0.5 px half-divider.
  • Claim: plain columns' lines sat on the divider. Verified: 0.5 px on the base code.
  • Claim: the drag target sat away from the visible edge, and a mixed table showed lines at two offsets. Verified: the 8 px strip and the line are one element.
  • Claim: every resize line now sits on its divider, in left-to-right and right-to-left. Verified: 0.5 px for every boundary on this head, at desktop width and at 390 px.
  • Claim: a sortable header's right-click menu still opens at the pointer. Verified within 0.5 px (see the non-blocking note).
  • Claim: the positioned menu trigger, not the header cell, contained the absolutely positioned boundary. Verified in code and in the browser.
  • Claim: inside a Table the trigger stays unpositioned and the cell is positioned; the menu measures from the anchor's containing block, still the trigger elsewhere; a sticky column's own position still wins. Verified (TableHeaderCell.tsx:97-110, :170-183; ContextMenu.tsx:618-626; sticky columns set their position inline).
  • Claim: a keyboard open still anchors at the trigger's bottom-left. Verified (at the trigger's bottom edge, 1 px lower than before).
  • Claim: the governing claims are the resize module's trailing-edge boundary and the menu's pointer anchor, which is unchanged. Verified.
  • Claim: the smallest restoration is the header cell, the menu, a story and a changeset. Verified; the shared predicate in tableContextMenu.tsx and TableCell.tsx also changed.
  • Claim: the stills show the Name line 11.5 px inside its divider before and on it after, in left-to-right, right-to-left and at 390 px. Verified: this review measured the same values.
  • Claim: by density the Name line sat 11.5, 7.5 and 15.5 px inside and 0.5 px after, with density passed only for the capture. Verified from the density paddings minus the 0.5 px half-divider; the committed story passes no density.
  • Claim: the new browser spec fails its two boundary tests before the fix (11.5 px) and passes its menu test, and all three pass on this head. Verified.
  • Claim: the menu cursor-anchor browser spec passes all 3 tests before and after. Verified.
  • Claim: the ContextMenu and Table unit suites pass (49 files, 962 tests), with no type errors and clean lint. Verified: the suites pass here, and CI's typecheck and lint pass on this head.
  • Claim: the browser check runs in CI's accessibility legs through its scope line. Verified: CI's browser-spec job selected it on this head and it passed.
  • Claim: one defect, no tagalongs, no new public API, default or interaction model, and no internal context. Verified: the API comparison lists no change.
  • Claim: fixes the linked issue. Verified: the issue reports this cause.
  • Changeset: a Core patch fix with the same description and a credit line. Verified.
  • File .changeset/table-resize-handle-sortable-edge.md: clear.
  • File apps/storybook/stories/TableColumnResize.stories.tsx: clear.
  • File packages/core/src/ContextMenu/ContextMenu.tsx: non-blocking 0.5 px anchor offset; one passive comment.
  • File packages/core/src/Table/TableCell.tsx: clear.
  • File packages/core/src/Table/TableHeaderCell.tsx: one long comment sentence (non-blocking).
  • File packages/core/src/Table/__tests__/TableColumnResizeEdge.a11y.chromium.spec.ts: clear; its menu check covers only the first column in left-to-right.
  • File packages/core/src/Table/tableContextMenu.tsx: clear.

Automated review (maintainer link)

const base = cursorAnchorRef.current?.offsetParent;
return (
base instanceof HTMLElement ? base : triggerRef.current
)?.getBoundingClientRect();

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.

Non-blocking, and a correction to the earlier note on this line: subtracting clientLeft and clientTop over-corrects. Under collapsed borders the header cell reports clientLeft 1 for its 0.5 px half-divider, so Role's anchor in left-to-right would move from x 516.5 to 515.5 for a pointer at 516. The anchor's own getBoundingClientRect() minus its current left and top gives the padding edge exactly.

Comment on lines +176 to +178
// interacts with its padding / content. No-op when no actions. Inside a
// Table the wrapper stays unpositioned, so a header plugin's overlay, such
// as a resize boundary, positions against the cell and sits on its edge.

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.

Non-blocking (INV29): the added sentence runs 26 words with two topics. Suggested split: "Inside a Table the wrapper stays unpositioned. A header plugin's overlay, such as a resize boundary, then positions against the cell and sits on its edge."

[listNavKeyDown, closeMenu, typeahead, ownsEvent],
);

// The box the cursor anchor's offsets are measured from: its containing

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.

Non-blocking (INV29): "are measured from" is passive. For example: "The cursor anchor's offsets start at its containing block."

@cixzhang
cixzhang marked this pull request as ready for review November 13, 2026 21:24
@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Nov 13, 2026
@cixzhang
cixzhang marked this pull request as draft November 13, 2026 22:06
@cixzhang
cixzhang marked this pull request as ready for review November 13, 2026 22:07
@cixzhang
cixzhang merged commit 8931e81 into main Nov 13, 2026
203 checks passed
@github-actions
github-actions Bot deleted the lane4/table-resize-handle-edge branch November 14, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — 5b78a3cc Deployed Nov 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Table: in sortable columns the resize handle sits a cell padding inside the column edge

1 participant