Architecture decision record · ADR-0026

Grid hooks, round 2

Header slots get a narrow grid API. The header slot and the floating filter get @grid, a GridHeaderApi with autoSizeColumns(columnIds?), not the GridStateHandle.

Status
Accepted
Deciders
Joe Gaudet
Created
Updated
PRD
PRD
Related
None

Context

Other tracks asked for more hooks after ADR 0023. The column menu sized columns with a synthetic double click on the separators. With a header slot, the name of a header cell had the names of the slot controls, so a query by name did not find it. The fill handle was the only path to a fill, and it is aria-hidden. The sheet wrote aria-describedby on the gridcell from its cell component, and the grid replaced it when a note or a tooltip opened. The live regions had no name. A guide test saw only the pinned header for one frame. An app could not open an editor with editTrigger: 'none'. Two harnesses (GridEditHarness and CellEditorHarness) both read the open editor. The maintainer was not available, so this ADR records the decisions. Contract section 12 has the DOM and the API.

Decision drivers

Not recorded in the original ADR.

Options considered

Not recorded in the original ADR.

Decision

  1. Header slots get a narrow grid API. The header slot and the floating filter get @grid, a GridHeaderApi with autoSizeColumns(columnIds?), not the GridStateHandle. A slot needs only this part, and a grid with no @stateHost still has it. With no IDs, it sizes the columns that can resize, as the menu did before. The column menu calls it, and has its auto-size items only when it gets @grid.
  2. The header name is the label. A leaf header cell with a header slot has aria-label with the label text. The slot controls keep their own names. A header with no slot keeps the name from its text: an aria-label there adds nothing, and a label query in an app test (label('Region') for a checkbox) would match the header too. GridHarness.header(name) and the lookups of a column by its header name read aria-label, else the text. GridEditHarness.editor(column) skips the header, because the header now has the same name as the editor control.
  3. Ctrl+D and Ctrl+R are in the grid. The keys of LatticeSheet moved to the grid, with the sheet semantics: the top row (or the first column) of the range fills it, and a range of one row (or one column) takes the row above (or the column at the inline start). The fill goes through @editing.fill, as the fill handle does: one undo step. The sheet removed its own keys, so a key press fills one time. As the fill handle, there is no keyboard fill with @rowModel.
  4. A cell description hook. meta.lattice.cellDescription(row, column) gives text, and meta.lattice.cellInvalid(row, column) gives aria-invalid. The grid owns aria-describedby: it puts the description ID first, then the tooltip and the note. The texts are in a hidden list in .lt-grid-root, so a reading of the cell text does not include them. A hook gives text, not an element ID: the grid then owns the element and the ID. The sheet surface gives both hooks. It keeps the async validation result of each cell in a map, as tracked state, keyed by the value, the rules and the locale text.
  5. The live regions have names: grid.messages for .lt-live and grid.status for .lt-overlay-message.
  6. The first render has the headers. The cause of the header flicker: the column virtualizer started with no columns and no size, so the first render had only the pinned columns. The modifiers then set the columns and the size, but the next render came in a later frame. A role query in that frame saw only the "Row" header. Now the column virtualizer starts with the center columns and the width of the window as initialRect. The scroller size replaces it when the grid mounts. The row virtualizer does not get a first size: with one, the bench first render was 55% slower (it renders the rows of the window, then the rows of the scroller). So the body rows still come in the render after the measure.
  7. GridStateHandle.startEditing(rowId, columnId) opens the editor through the same path as F2. It is on the handle, beside scrollToCell, because an app that starts an edit from a button or a route has the handle, not a cell.
  8. One editor harness. GridEditHarness has the reads and actions of CellEditorHarness, with names that say where they work: editorState, editorErrors, isEditorFocused(), pressInEditor, typeInEditor and clickInEditor. editorMode gives cell, popup or null. CellEditorHarness is gone: no test needs both names.

Consequences

  • An app with a custom header slot gets @grid; a slot that does not read it is not changed.
  • The first render can render more columns than the scroller shows, up to the window width. The next render, after the measure, removes them.
  • Limit: in the first frame of a grid, the body has only the first row. A row query right after the first render sees one row.
  • A test that found a header by its text with slot controls in it now finds it by its label.

Confirmation

Not recorded in the original ADR.

Interview record

Each question of the interview with its answer and its source. A fact from the code or a document, a question that the author did not ask, and an assumption are rows too.

QuestionAnswerSource
Where does the text of this page come from?From the Markdown file docs/adr/0026-grid-hooks-round-2.md at commit 4c77ac4. The text of each section is the text of the Markdown file. A section that the Markdown file does not have says so.Document: docs/adr/0026-grid-hooks-round-2.md

Changelog

DateAuthorChange
2026-12-02Joe GaudetStatus in the Markdown file: accepted, 2026-12-02.
2026-12-03Joe GaudetCommit 7ce4af2: Lattice 1.0 (#1)
2026-12-04Joe Gaudet (agent)Converted from docs/adr/0026-grid-hooks-round-2.md to this page. The text is the text of the Markdown file.

The adr skill of skillsaw wrote this page. The HTML in this file is the source of truth. The diagrams are the Mermaid sources in it.