Architecture decision record · ADR-0023

Grid column sizing, aligned grids, external filter, notes and hooks

Flex widths. The grid calls core applyFlexWidths with the clientWidth of the scroller.

Status
Accepted
Deciders
Joe Gaudet
Created
Updated
PRD
PRD
Related
None

Context

The parity matrix had flex widths, auto-size, auto-generated columns, aligned grids, the external filter and notes as "planned" or "partial" in the Grid. Other tracks asked for hooks: the range on the context menu API, a header label slot, a row header role for row numbers, a row editor that a nested grid does not confuse, a long press that opens one menu, and the format of column types. Research S13 asked for a new name of the row data-slot attribute. The maintainer was not available, so this ADR records the decisions. Contract section 11 has the DOM and the API.

Decision drivers

Not recorded in the original ADR.

Options considered

Not recorded in the original ADR.

Decision

  1. Flex widths. The grid calls core applyFlexWidths with the clientWidth of the scroller. It does this in the next animation frame after a ResizeObserver call or a change of the column sizes, visibility or order. A write in the ResizeObserver callback can show a scroll bar and loop. A key of the width and the sizes of the columns that are not flex skips a pass with the same input. A grid with no flex column does no pass.
  2. A resize takes a column out of flex, as in AG Grid. The grid keeps a set of these column IDs. The next pass gives the column no share, so it keeps its new size, and the other flex columns share the rest. An auto-size does the same.
  3. Auto-size measures the DOM. For each rendered cell of the column, the measure is the width of a Range over the cell content (for a header: the label and the slot), plus the padding and the border. A Range gives the content width, also when the content is narrower than the cell, so a column can shrink. The grid divides by the scale of the page. Only the rendered rows and columns count: a column that is not rendered keeps its size. AG Grid also measures only the rendered rows.
  4. Auto-size API. A double click on the separator sizes its column. GridStateHandle.autoSizeColumns(columnIds?) sizes all columns or some. The handle is the API of the grid already (scrollToCell).
  5. Auto-generated columns. autoColumns(rows, { sample, types }) makes a column def for each key of the first rows. The header is the key in words (owner_name → Owner name). A key gets the first type whose isValue takes its first value. A table with no leaf columns gets these columns after the render in which it first has rows, through table.setOptions. So rows that load later also get columns. The grid never writes state during render. setOptions is not in GridTable, because its updater type is the options type of the app; the grid finds it at run time.
  6. Column types. meta.columnType is a structural type (format(value, locale)), so @ember-lattice/ember does not depend on @ember-lattice/column-types. A cheap cell shows type.format(value, @locale). meta.lattice.format wins.
  7. Aligned grids use a shared handle. LatticeGrid.alignment() gives a GridAlignment. Each grid with it as @aligned joins it. A grid that joins takes the column state of the first grid. A change of the sizes, the order state or the visibility goes to the other grids, for the column IDs that they share. Each grid compares before it writes, so the change stops after one round. The modifier that sends a change does its work after the render ends: a modifier tracks what it reads, and a read of the other table in it made a render loop. The order is the visible order of the columns, not the column order atom. A horizontal scroll sets scrollLeft of the other grids when it is different. A handle, not @alignedWith={{grid}}: two or more grids can share it, and no grid needs a reference to another component.
  8. The external filter is one function. @externalFilter is (row) => boolean. When the arg is given, the filter is on; AG Grid needs two callbacks for this. The grid filters the rows of the row model (not the pinned rows) in its rows getter, so tracked state that the function reads filters again with no "filter changed" call. Limit: the engine groups before this filter, so group rows keep their counts, and select-all and export use the table.
  9. Notes in the grid. @notes has noteAt(rowId, columnId), as @find has matchAt. A cell with a note has data-note; the theme draws a corner mark. Hover or focus shows div.lt-note role="note" in .lt-grid-root, outside role=grid, under the cell. The cell gets aria-describedby, with the tooltip ID too when both are open. Then the note goes under the tooltip, so the two do not overlap. The note follows its cell on a scroll, and hides when the cell is not rendered. The sheet can use @notes in place of its own note box.
  10. Hooks.
    • GridContextMenuApi.selection gives the ranges, also the grid range of @rowModel.
    • meta.lattice.headerLabel (Args { column, label }) replaces the label text. A click on a control in it does not sort or drag. F2 and Escape work as in the header slot.
    • The row number cells are role="rowheader". The keys, the focus and the harness accept the role.
    • placeRowEditor finds the row and the cells of this grid only, with :scope > paths, as cellElement does. placeEditor already used cellElement.
    • The sticky group rows read a group end map that the grid makes in one pass when the rows change. Before, each range change scanned each open group to its end.
    • A contextmenu event ends a long press that runs, so Android opens one menu.
  11. A covered cell under a merge of many columns leaves a spacer as wide as the column span of the merge, not one column. Before, the cells after a merge of more than one row and more than one column moved to the wrong place in the rows under the anchor. This changes ADR 0018, item 11.
  12. The sheet merge box is gone. The sheet uses real spans, so the theme has no .lt-sheet-merge rule. The theme styles the function help list (.lt-sheet-help) of the formula bar.
  13. The row slot attribute is data-lt-slot. Joinery's scoped preflight matches [data-slot] and [data-slot] *. The rename stops it on rows and cells (research S13, C1). The harness does not read the attribute.

Consequences

  • The matrix rows "Flex widths", "Auto-size", "Auto-generated columns", "Aligned grids", "External filter", "Notes" and "Column data types" are "done", each with its Grid test.
  • A theme fixture (fixtures/grid-rows.html) tests the row feature CSS. It found two faults: editing.css made full-width cells position: relative (not sticky), and forced colors removed the drag handle dots.
  • The external filter, the auto-size measure and the note position have shortcut: comments or limits in this ADR.

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/0023-grid-columns-and-hooks.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/0023-grid-columns-and-hooks.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/0023-grid-columns-and-hooks.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.