Skip to content
Draft
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/table-cell-lazy-context-menu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astryxdesign/core': patch
---

[perf] TableCell and TableHeaderCell load their right-click context menu only when the cell has `contextMenuActions`. A table without context menus no longer ships ContextMenu, DropdownMenu's menu code and the touch sheet: a page that renders Table, Text and Button loads about 23 to 25 KB less JavaScript (gzip) on first load in Vite, Rolldown and webpack. A cell with actions renders its content at once and starts loading its menu on its first client render; the content keeps its DOM node, focus and state when the menu attaches. A right-click, Shift+F10 or long press that arrives before then is held and opens the cell's menu when it loads, unless another press or key comes first, so the browser's own menu does not appear. If the menu code fails to load, the table stays and the browser's own menu returns; a later mount, or a later right-click or touch on that cell, asks the module loader again. A test that expects the menu synchronously right after render has to wait for it to load. `resolveContextActions` keeps its export and no longer pulls the menu in.

@rhagigi @cixzhang
29 changes: 14 additions & 15 deletions docs/architecture/component-import-boundaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ one allowlist row. A module that an `import()` targets is a surface module.

Some modules in a surface or capability folder are base code: the trigger
contract a surface folder keeps for base imports
(`Tooltip/tooltipPresentInterest`, `Layer/layerScopedContext`), and a
(`Tooltip/tooltipPresentInterest`, `Layer/layerScopedContext`,
`ContextMenu/ContextMenuTrigger`, and `Layer/gestureCounter`, which a trigger
reads to drop a held intent at a later press or key), and a
capability's own import (a Table plugin's folder index and the modules it
re-exports, and `SnapPaging/SnapPaging`). INV7's wiring lives in base code:
the component's own modules or the capability's own import. A wiring module
Expand Down Expand Up @@ -213,20 +215,20 @@ one pending load per module, caches a success, and resets after a failure.

### Allowlist

| Crossing (base module → module it imports statically) | Entries that reach it | Cost, gzip | Invariant | Row leaves when |
| ----------------------------------------------------------------- | ---------------------------------------------- | ---------------------- | ---------- | ------------------------------------------------------------------------------------------------------ |
| `Text/TruncationTooltip` → `Layer/gestureCounter` | Text, Heading, Button, IconButton, Link, Table | 1.7 KB (Text, Heading) | INV1, INV8 | the truncation tooltip's eager code carries no touch tap recognizer; the row moves with the recognizer |
| `Button/Button` → `Tooltip/useTooltip` | Button, IconButton | 19.5 KB | INV1 | Button's tooltip layer code is lazy |
| `Link/Link` → `Tooltip` | Link | 21.6 KB | INV1 | Link's tooltip layer code is lazy |
| `Table/tableContextMenu` → `ContextMenu` | Table | 88.5 KB | INV1 | cells without actions reach no menu module |
| `Table/BaseTable` → `Table/plugins/virtualization/useTableWindow` | Table | 3.6 KB | INV7 | a Table that never windows reaches neither the controller nor its engine |
| Crossing (base module → module it imports statically) | Entries that reach it | Cost, gzip | Invariant | Row leaves when |
| ----------------------------------------------------------------- | ---------------------------------------------- | ---------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `Text/TruncationTooltip` → `Layer/gestureCounter` | Text, Heading, Button, IconButton, Link, Table | 1.7 KB (Text, Heading) | INV1, INV8 | the truncation tooltip's eager code carries no touch tap recognizer; the row moves with the recognizer |
| `Button/Button` → `Tooltip/useTooltip` | Button, IconButton | 19.7 KB | INV1 | Button's tooltip layer code is lazy |
| `Link/Link` → `Tooltip` | Link | 21.7 KB | INV1 | Link's tooltip layer code is lazy |
| `Table/TableCellContextMenu` → `Layer/gestureCounter` | Table | 0.0 KB | INV8 | a cell's menu wrapper reads the gesture identity from a module without the touch tap recognizer; the row moves with the recognizer |
| `Table/BaseTable` → `Table/plugins/virtualization/useTableWindow` | Table | 3.5 KB | INV7 | a Table that never windows reaches neither the controller nor its engine |

Costs are the check's own printout in CI: each crossing's removal from the
entry with every other crossing kept, in the entry build above. A local run
on another platform or Node version can print gzip sizes a few tenths of a KB
apart. Rows share modules, so they do not add up. The truncation tooltip's touch code costs Button,
IconButton, Link, and Table nothing on its own, because another of their
crossings brings the same module. Table carries 134.5 KB eager.
crossings brings the same module. Table carries 50.5 KB eager.

### Must not reach

Expand Down Expand Up @@ -260,16 +262,13 @@ an allowlist row does.
`Popover`, and `ContextMenu` are not in INV9's entry list, and
`DropdownMenu` is an entry whose crossings are not checked.
- INV1 gap: Button's and IconButton's imports reach the tooltip hook and the
layer runtime, 19.5 KB gzip, with or without a `tooltip` prop. Through
layer runtime, 19.7 KB gzip, with or without a `tooltip` prop. Through
Button, Link, or their own code, 32 of Core's 95 component imports that are
not surfaces carry 17–24 KB of tooltip code, and 52 carry at least 1 KB.
- INV1 gap: Link's import reaches the Tooltip component and the layer
runtime, 21.6 KB gzip, with or without a `tooltip` prop.
- INV1 gap: Table's import reaches the cell context menu, 88.5 KB gzip, for
cells with no actions, while `component:TableCell` PR1 loads a menu only
when actions are given.
runtime, 21.7 KB gzip, with or without a `tooltip` prop.
- INV7 gap: Table's import reaches the window controller and the shared
windowing module, 3.6 KB gzip, for a Table that never windows.
windowing module, 3.5 KB gzip, for a Table that never windows.
- INV3 gap: no record says how a tooltip's description reaches assistive
technology before its surface loads, for the triggers whose tooltip is
their description.
Expand Down
Loading