Repository navigation
fix(Table, ContextMenu): a sortable column's resize line sits on its column edge - #11576
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec 0e822bd |
PR Analysis Report🔎 Preview ·
|
| 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
There was a problem hiding this comment.
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-155copieshasContextMenufromTableCell.tsx:222-224, and both re-decide whatwrapInTableContextMenudecides, 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 fromtableContextMenu.tsxand 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: relativeon 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, copiedhasContextMenupredicate; 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.
| const base = cursorAnchorRef.current?.offsetParent; | ||
| return ( | ||
| base instanceof HTMLElement ? base : triggerRef.current | ||
| )?.getBoundingClientRect(); |
There was a problem hiding this comment.
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.
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.
|
/approve-spec 5b78a3c |
There was a problem hiding this comment.
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
leftandtopapply from its padding edge; taking the origin from the anchor's own rect minus its currentleftandtopkeeps it on the pointer. - Two new comments could be tighter: the last sentence of
TableHeaderCell.tsx:176-178runs 26 words, andContextMenu.tsx:618is 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.tsxandTableCell.tsxalso 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.
| const base = cursorAnchorRef.current?.offsetParent; | ||
| return ( | ||
| base instanceof HTMLElement ? base : triggerRef.current | ||
| )?.getBoundingClientRect(); |
There was a problem hiding this comment.
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.
| // 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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Non-blocking (INV29): "are measured from" is passive. For example: "The cursor anchor's offsets start at its containing block."
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
TableHeaderCellwraps the header's content in the menu's trigger. That trigger isposition: relativeso it can hold the menu's cursor anchor. The resize boundary renders inside the header content and is absolutely positioned withinset-inline-end: 0, so the trigger, not the header cell, becomes its containing block, and the trigger sits inside the cell's padding.Expected behavior and authority
module:Table/useTableColumnResizeFR1: 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.WithSortableColumnsstory forCore/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.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.
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
densityto the Table in both builds; product code is unchanged.Table/__tests__/TableColumnResizeEdge.a11y.chromium.spec.tsat the test commit alone (mainplus 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).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 atmainand at this head.Scope
Testing
pnpm exec vitest run packages/core/src/ContextMenu packages/core/src/Table: 49 files, 962 tests pass.tsc --noEmitfor@astryxdesign/core: clean.@pr-a11yscope 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.