Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
dash: header click selects, inline column rename, typed Add column, copy marks, formula point mode, Esc closes Story/Pivot (#808)
nyblnetbdb8b5049878
diff --git a/.github/workflows/ci-dash.yml b/.github/workflows/ci-dash.ymlindex a57d3ac8..48f15c2c 100644--- a/.github/workflows/ci-dash.yml+++ b/.github/workflows/ci-dash.yml@@ -62,6 +62,13 @@ jobs:# positive control, light and dark; bare checkboxes; a formula over# Money is Money and one column never mixes grouping.run: node scripts/test-dash-panel-context-browser.mjs+ - name: The grid's core gestures, with a real mouse and keyboard+ # A header click selects the column and never sorts (sort lives in ▾,+ # and the selection follows its row); double-click renames in place;+ # Add a column picks the type; the type chip reads at 11px; ⌘C draws+ # marching ants; point mode inserts references (dataset and+ # spreadsheet, other sheets by tab); Escape closes Story and Pivot.+ run: node scripts/test-dash-gestures-browser.mjsdash-gate-browser:runs-on: ubuntu-latestdiff --git a/dash/CHANGELOG.md b/dash/CHANGELOG.mdindex 6b36ac35..b397b74d 100644--- a/dash/CHANGELOG.md+++ b/dash/CHANGELOG.md@@ -254,6 +254,32 @@ The release that came out of watching somebody use 0.2.0.beside `24,800`: without a pattern it does not group thousands (as Excel'sGeneral does not), and a `#,##0` pattern groups every value.+- **Clicking a column header selects the column; it no longer sorts.**+ Shift-click extends the selection and ⌘-click (Ctrl-click) adds a column,+ on datasets and on spreadsheet column letters alike. Sorting is in the+ header's ▾ menu and the right-click menu. After a sort or filter, the+ selected cell stays on the same record instead of the same screen position.++- **Double-click a column name to rename it** right on the grid. Enter keeps+ the new name (one undo step), Escape leaves it as it was.++- **+ Add a column asks for the type** as well as the name. The type label on+ each column header is larger (11px) and no longer crowds the column letter.++- **Copying shows what was copied.** ⌘C or ⌘X draws a moving dashed border+ around the range until you press Escape, make the next edit, or paste.++- **Click a cell to put it in a formula.** While typing a formula, after `=`,+ an operator, `(` or `,`, clicking a cell or pressing an arrow key inserts+ its address instead of finishing the edit. Shift-click, shift-arrow or a+ drag makes a range, shown highlighted on the grid. Clicking another sheet's+ tab inserts a reference to that sheet (`Pipeline!A1`), which the arrow keys+ then move. Enter finishes the formula. This works in spreadsheet cells and in+ a dataset's per-cell formulas, where a sorted view still refers to the right+ row.++- **Escape closes the Story and Pivot panels.**+## [0.2.0] — 2026-08-03First release. A workbook is one self-contained HTML file: the data, the grid,diff --git a/dash/src/grid.ts b/dash/src/grid.tsindex c85dc31b..61e61a87 100644--- a/dash/src/grid.ts+++ b/dash/src/grid.ts@@ -25,12 +25,13 @@ import { appearanceCss } from './cellfmt.ts'import { readCell, type Patch, type Store } from './store.ts'import { recalc, isErr, type Vec } from './formula.ts'import {- Selection, keyToAction, applyMotion, contains, tsvFromRange, parseTsv,+ Selection, keyToAction, applyMotion, contains, normalize, tsvFromRange, parseTsv,fillCells, type Box, type FillCell, type FillMode, type Range,} from './select.ts'import { buildOrder, type ColumnFilter } from './filter.ts'import { evaluateRules, type CellStyle } from './condfmt.ts'import { colToLetters, formatRef, parseRef } from './a1.ts'+import { acceptsRef, refText, type Pos } from './pointref.ts'import { t } from './i18n.ts'import { resizeColumn, autoFitWidth, hiddenSet, readFrozen, insertRowsAt } from './rowcol.ts'import {@@ -624,6 +625,10 @@ export class Grid {store: this.store, grid: this, el: this.host, coerce: coerceForColumn,})this.store.on('doc', () => {+ // The next edit ends the copy marks, as in every spreadsheet: what the+ // ants outline is "what a paste would bring", and an edit (a paste+ // included) is the moment that stops being a promise worth drawing.+ this.copyMark = null// A canvas sheet has no order vector and no columns to count — its extent// comes out of its own keys, and `paintCanvas` sizes the selection from// it. All this listener owes it is "the cells changed, look again".@@ -884,6 +889,10 @@ export class Grid {this.noteEl = this.host.querySelector('.dg-note')!this.descEl = this.host.querySelector('.dg-a11y')!this.scroller.addEventListener('scroll', () => this.paint(), { passive: true })+ // Point mode claims a click on a cell BEFORE the cell's own mousedown sees+ // it (capture), because that handler moves the selection and the blur it+ // causes commits the formula half-typed.+ this.scroller.addEventListener('mousedown', (e) => this.pointMouse(e), true)// A CLIPPED CELL HAD NO WAY TO BE READ. `.dg-cell` is// `overflow:hidden; text-overflow:ellipsis`, so a value wider than its// column ends in an ellipsis and the rest is simply gone. Measured on the@@ -988,7 +997,7 @@ export class Grid {const filtered = this.filters.some((f) => f.col === c.id)const fz = this.freeze(ci)// `aria-sort` IS THE SORT INDICATOR for anyone not looking at the ▲.- // Every dataset column is sortable (clicking the name sorts it), and+ // Every dataset column is sortable (from the ▾ menu), and// `none` is ARIA's word for "sortable, not currently sorted" — omitting// it entirely would say the column cannot be sorted at all. The sorted// one is read off `this.sorts`, not `this.sort`, so a shift-click's@@ -1006,8 +1015,7 @@ export class Grid {// and with only one of the two the eye keeps losing which column it is// in on a wide sheet — the header is the only thing still on screen once// the cursor has scrolled away.- const box = this.sel.bounds()- const on = ci >= box.left && ci <= box.right ? ' dg-h-on' : ''+ const on = this.colLit(ci) ? ' dg-h-on' : ''return `<div class="dg-cell dg-h${filtered ? ' dg-filtered' : ''}${on}${fz.cls}" ` +`role="columnheader" aria-colindex="${ariaColIndex(ci)}" tabindex="-1"${sortAttr}${label} ` +`style="${fz.st}width:${c.w ?? 130}px" data-col="${c.id}" data-ci="${ci}">` +@@ -1382,6 +1390,8 @@ export class Grid {// A repaint detaches the arrow the menu was dropped from, and the menu is// mounted on the body — so it would hang there over a grid that has moved.closeListMenu()+ // A paint rebuilds the rows, and the pointed-at highlight with them.+ this.point = null// Captured BEFORE any innerHTML is replaced: afterwards the previously// focused node is detached and `contains` answers false for it, so this is// the only moment the question "did the grid have focus?" can be asked.@@ -1538,7 +1548,7 @@ export class Grid {}this.paintEmptyGrid(gridN * ROW_H)this.head.innerHTML = this.header()- this.table.innerHTML = body.join('') + this.outline()+ this.table.innerHTML = body.join('') + this.outline() + this.antsHtml((b) => this.datasetRect(b))// `totalsRow()` returns '' when the sheet declares no totals, but the// element keeps its 2px top rule and its 20px of height — so a sheet with// no totals drew a heavy line across the grid under nothing at all. Hide@@ -1958,10 +1968,71 @@ export class Grid {* one of them forgets to set `clip.cut` and pastes a copy instead.*/copyToClipboard(cut: boolean): void {- void navigator.clipboard?.writeText(this.copyTsv())- if (!cut) return- if (this.clip) this.clip.cut = true- this.clearSelection()+ navigator.clipboard?.writeText(this.copyTsv()).catch(() => { /* a browser that refuses the clipboard still gets the internal clip */ })+ const box = this.sel.bounds()+ if (cut) {+ if (this.clip) this.clip.cut = true+ this.clearSelection()+ }+ // THE MARCHING ANTS. Set AFTER a cut's clear, whose own doc event would+ // otherwise count as "the next edit" and take them straight down again.+ this.copyMark = { sheet: this.sheetId, box }+ this.paint()+ }++ /**+ * What was last copied, outlined with a dashed "marching ants" border until+ * Escape, the next edit, a paste, or a view change, as in Excel, Sheets and+ * Numbers. Without it ⌘C changed nothing on screen and the only proof that+ * anything had been copied was pasting it somewhere.+ */+ private copyMark: { sheet: string; box: Box } | null = null++ /** Is something marked as copied? (the rig's and Escape's question) */+ hasCopyMark(): boolean { return this.copyMark !== null }++ clearCopyMark(): boolean {+ if (!this.copyMark) return false+ this.copyMark = null+ this.paint()+ return true+ }++ /** The ants, as a box over the rows; `place` turns a Box into geometry. */+ private antsHtml(place: (b: Box) => { left: number; top: number; width: number; height: number } | null): string {+ const m = this.copyMark+ if (!m || m.sheet !== this.sheetId) return ''+ const g = place(m.box)+ if (!g) return ''+ return `<div class="dg-ants" aria-hidden="true" style="left:${g.left}px;top:${g.top}px;width:${g.width}px;height:${g.height}px"></div>`+ }++ /** A visible-position box → its rectangle on the dataset sizer. */+ private datasetRect(b: Box): { left: number; top: number; width: number; height: number } | null {+ const vis = cols(this.sheet)+ if (!vis.length) return null+ const w = (i: number) => vis[i]?.w ?? 130+ let left = GUTTER_W+ for (let i = 0; i < b.left; i++) left += w(i)+ let width = 0+ for (let i = b.left; i <= b.right && i < vis.length; i++) width += w(i)+ return { left, top: b.top * ROW_H, width, height: (b.bottom - b.top + 1) * ROW_H }+ }++ /** The same for a spreadsheet, whose rows and columns each have a size. */+ private canvasRect(b: Box): { left: number; top: number; width: number; height: number } | null {+ const s = this.canvas+ if (!s) return null+ const n = Math.max(b.bottom + 1, this.sel.rows)+ const rs = this.rowSizes(s, n)+ const lefts = this.colLefts(s, Math.max(b.right + 1, 1))+ const left = lefts[b.left]+ const top = rs.top(b.top)+ return {+ left, top,+ width: lefts[b.right + 1] - left,+ height: rs.top(b.bottom) + rs.height(b.bottom) - top,+ }}copyTsv(): string {@@ -2357,6 +2428,7 @@ export class Grid {/** The full keyboard set, routed through select.ts's typed actions. */handleKey(e: KeyboardEvent): boolean {if (this.editing || this.cvEditing) return false+ if (e.key === 'Escape' && !e.metaKey && !e.ctrlKey && !e.altKey && this.clearCopyMark()) return trueconst a = keyToAction(e)if (!a) return falseif (a.kind === 'edit') return this.editActive()@@ -2806,7 +2878,7 @@ export class Grid {const surface = this.table.parentElement!surface.style.backgroundImage = ''this.head.innerHTML = this.canvasHeader(c0, c1, lefts, padLeft, box)- this.table.innerHTML = body.join('') + this.canvasOutline(rs, lefts, ext)+ this.table.innerHTML = body.join('') + this.canvasOutline(rs, lefts, ext) + this.antsHtml((b) => this.canvasRect(b))this.foot.hidden = truethis.foot.innerHTML = ''this.foot.removeAttribute('aria-rowindex')@@ -2827,12 +2899,12 @@ export class Grid {* spreadsheet's columns are not typed and cannot be — see the header note. */private canvasHeader(c0: number, c1: number, lefts: number[], padLeft: number,- box: { left: number; right: number },+ _box: { left: number; right: number },): string {const pad = padLeft > 0 ? `<div class="dg-cell dg-pad" style="width:${padLeft}px"></div>` : ''let out = `<div class="dg-cell dg-corner" role="columnheader" aria-colindex="1" tabindex="-1" data-all="1" title="${esc(t('Select every cell in the sheet'))}"></div>${pad}`for (let c = c0; c < c1; c++) {- const on = c >= box.left && c <= box.right ? ' dg-h-on' : ''+ const on = this.colLit(c) ? ' dg-h-on' : ''// NO `aria-sort`: a spreadsheet's columns are not sortable, and `none`// would say they are but are not sorted, which is a different claim.out += `<div class="dg-cell dg-h dg-ch${on}" role="columnheader" aria-colindex="${ariaColIndex(c)}" tabindex="-1" data-ci="${c}" style="width:${lefts[c + 1] - lefts[c]}px">` +@@ -2889,12 +2961,13 @@ export class Grid {document.addEventListener('mouseup', up)}}- this.head.querySelectorAll<HTMLElement>('.dg-letter').forEach((el) => {- el.onclick = () => {- const ci = Number(el.closest<HTMLElement>('[data-ci]')?.dataset.ci)- if (!Number.isFinite(ci)) return- this.sel.selectCol(ci)- this.paint(); this.announce()+ // The whole letter cell selects the column, shift extends, ⌘ adds — the+ // same gesture as a dataset header (see `wire`).+ this.head.querySelectorAll<HTMLElement>('.dg-h[data-ci]').forEach((el) => {+ el.onmousedown = (e) => {+ if (e.button !== 0) return+ if ((e.target as HTMLElement).dataset.cgrip !== undefined) return+ this.headerSelect(Number(el.dataset.ci), e)}})const corner = this.head.querySelector<HTMLElement>('.dg-corner')@@ -3090,6 +3163,7 @@ export class Grid {cell.onblur = () => finish(true)cell.onkeydown = (e) => {e.stopPropagation()+ if (this.pointKey(e)) returnif (e.key === 'Enter') { e.preventDefault(); finish(true, e.shiftKey ? 'up' : 'down'); return }if (e.key === 'Tab') { e.preventDefault(); finish(true, e.shiftKey ? 'left' : 'right'); return }if (e.key === 'Escape') { e.preventDefault(); finish(false) }@@ -3248,24 +3322,29 @@ export class Grid {document.addEventListener('mouseup', up)}}- this.head.querySelectorAll<HTMLElement>('.dg-name').forEach((el) => {- el.onclick = () => {- const col = el.closest<HTMLElement>('[data-col]')?.dataset.col- if (col) this.toggleSort(col)- }- })- // select a whole column by its letter, the whole sheet by the corner- this.head.querySelectorAll<HTMLElement>('.dg-letter').forEach((el) => {- el.onclick = () => {- // `closest`, not `parentElement`: the letter sits inside a strip now,- // and reading `ci` off the immediate parent gave NaN the moment the- // header grew a second line.- const ci = Number(el.closest<HTMLElement>('[data-ci]')?.dataset.ci)- if (!Number.isFinite(ci)) return- this.sel.selectCol(ci)- this.paint(); this.announce()+ // A HEADER CLICK SELECTS THE COLUMN. It used to SORT, which is the opposite+ // of what Excel, Sheets, Numbers and Airtable all do, and the selection+ // stayed on the old rectangle, which after the sort covered different rows.+ // Sorting is a command now (the ▾ menu and the right-click menu), never a+ // side effect of aiming at a column. Shift extends, ⌘/Ctrl adds.+ this.head.querySelectorAll<HTMLElement>('.dg-h[data-ci]').forEach((el) => {+ el.onmousedown = (e) => {+ if (e.button !== 0) return+ // the grip, the type chip, the ▾ and an open rename have their own jobs+ if ((e.target as HTMLElement).closest('[data-grip], [data-retype], [data-filter], .dg-rename')) return+ this.headerSelect(Number(el.dataset.ci), e)}})+ // Double-click the NAME renames the column in place (Airtable's gesture).+ // On the header ROW, which outlives every paint, rather than on the name+ // node, which a paint between the two clicks would replace.+ this.head.ondblclick = (e) => {+ const name = (e.target as HTMLElement | null)?.closest?.('.dg-name')+ const col = name?.closest<HTMLElement>('[data-col]')?.dataset.col+ if (!col || this.canvas) return+ e.stopPropagation()+ this.renameColumnInPlace(col)+ }// THE COLUMN GUTTER, right-clicked. On the WHOLE header cell and not just// the letter strip: the reader aiming at "this column" aims at the name,// the type badge or the letter without distinguishing between them, and a@@ -3448,30 +3527,154 @@ export class Grid {* Sorting is VIEW state. It sorts the order vector and never the data, so it* takes no checkpoint, sets no dirty flag and produces no op.*/- private toggleSort(colId: string): void {- const dir = this.sort?.col === colId && this.sort.dir === 'asc' ? 'desc' : 'asc'- this.sort = { col: colId, dir }- // Shift-click accumulates keys; a plain click replaces them. filter.ts's- // buildOrder does the multi-key comparison and sinks blanks in BOTH- // directions, which the hand-rolled single-key sort here did not.- this.sorts = [{ col: colId, dir }]- this.applyView()- }-- /** Add or replace a sort key without clearing the others — shift-click. */+ /** Add or replace a sort key without clearing the others. filter.ts's+ * buildOrder does the multi-key comparison and sinks blanks both ways. */addSort(colId: string, dir: 'asc' | 'desc'): void {- this.sorts = this.sorts.filter((k) => k.col !== colId).concat({ col: colId, dir })- this.sort = { col: colId, dir }- this.applyView()+ this.keepRows(() => {+ this.sorts = this.sorts.filter((k) => k.col !== colId).concat({ col: colId, dir })+ this.sort = { col: colId, dir }+ this.applyView()+ })}setFilter(colId: string, f: ColumnFilter | null): void {- this.filters = this.filters.filter((x) => x.col !== colId)- if (f) this.filters.push(f)- this.applyView()+ this.keepRows(() => {+ this.filters = this.filters.filter((x) => x.col !== colId)+ if (f) this.filters.push(f)+ this.applyView()+ })+ }++ clearView(): void {+ this.keepRows(() => { this.filters = []; this.sorts = []; this.sort = null; this.applyView() })+ }++ /**+ * A VIEW CHANGE MUST NOT MOVE THE SELECTION ONTO OTHER ROWS.+ *+ * The selection is held in VISIBLE positions (select.ts says why), so a sort+ * or filter that reorders the rows underneath it left the highlight on the+ * same screen rectangle, which now covered different records: the review+ * sorted by Owner and the selection sat over rows nobody had picked. Here the+ * selected ROWS are followed by identity instead:+ * • whole columns stay whole columns (they cover every row either way);+ * • single-row ranges, cells included, move to wherever their row went;+ * • a taller block cannot stay a block once its rows scatter, so it+ * collapses to the cursor cell, which follows its row.+ * A row the new view hides takes the cursor to the top. The copy marks go:+ * they described positions that no longer hold what was copied.+ */+ private keepRows(change: () => void): void {+ if (this.canvas) { change(); return }+ const s = this.sheet+ const rows0 = this.sel.rows+ const ridOf = (v: number): number => ridAt(this.store, s, v)+ const ranges = this.sel.ranges().map(normalize)+ const whole = ranges.every((b) => b.top === 0 && b.bottom >= rows0 - 1)+ const thin = ranges.every((b) => b.top === b.bottom)+ const rangeRids = ranges.map((b) => ridOf(b.top))+ const curRid = ridOf(this.sel.cursor.row)+ const cur = { ...this.sel.cursor }+ this.copyMark = null+ change()+ this.sel.resize(this.selRows(), cols(s).length)+ const order = this.store.order[s.id]+ const posOf = (rid: number): number => {+ if (rid < 0) return -1+ const r = dataRow(s, rid)+ if (r < 0) return -1+ return order ? order.indexOf(r) : r+ }+ if (whole) {+ const all = ranges.map((b) => ({ anchor: { row: 0, col: b.left }, head: { row: this.sel.rows - 1, col: b.right } }))+ this.sel.moveTo(0, ranges[0].left)+ this.sel.active = all[all.length - 1]+ this.sel.extra = all.slice(0, -1)+ this.sel.cursor = this.sel.clamp(Math.max(0, posOf(curRid)), cur.col)+ } else if (thin && rangeRids.every((r) => posOf(r) >= 0)) {+ const moved = ranges.map((b, i) => {+ const row = posOf(rangeRids[i])+ return { anchor: { row, col: b.left }, head: { row, col: b.right } }+ })+ const at = posOf(curRid)+ this.sel.moveTo(at >= 0 ? at : moved[moved.length - 1].anchor.row, cur.col)+ this.sel.active = moved[moved.length - 1]+ this.sel.extra = moved.slice(0, -1)+ } else {+ const at = posOf(curRid)+ this.sel.moveTo(at >= 0 ? at : 0, cur.col)+ }+ this.paint()+ this.announce()}- clearView(): void { this.filters = []; this.sorts = []; this.sort = null; this.applyView() }+ /**+ * A header mousedown: select the column (plain), extend to it (shift), add+ * it (⌘/Ctrl). Shared by both sheet kinds.+ */+ private headerSelect(ci: number, e: MouseEvent): void {+ if (!Number.isFinite(ci)) return+ const was = JSON.stringify([this.sel.ranges(), this.sel.cursor])+ if (e.shiftKey) this.sel.extendCol(ci)+ else if (e.metaKey || e.ctrlKey) this.sel.addCol(ci)+ else this.sel.selectCol(ci)+ // NO REPAINT WHEN NOTHING CHANGED. The second click of a double-click+ // lands on a column the first one already selected; repainting there+ // replaced the header under the pointer between mousedown and mouseup, so+ // the dblclick went to the header ROW and the rename never opened.+ if (JSON.stringify([this.sel.ranges(), this.sel.cursor]) === was) { this.focusGrid(); return }+ this.paint(); this.announce(); this.focusGrid()+ }++ /** Does any selected range cover visible column `ci`? (the lit headers) —+ * per range, not the bounding box, or ⌘-clicking B then E lit C and D. */+ private colLit(ci: number): boolean {+ return this.sel.ranges().some((r) => {+ const b = normalize(r)+ return ci >= b.left && ci <= b.right+ })+ }++ /**+ * Rename a dataset column ON the grid: the name becomes a field, Enter or a+ * click away commits ONE `setColumn` (one undo step, the same patch the+ * panel's Name field writes), Escape puts the old name back untouched.+ */+ private renameColumnInPlace(colId: string): void {+ if (this.store.readOnly || this.canvas) return+ const cell = this.head.querySelector<HTMLElement>(`.dg-h[data-col="${colId}"]`)+ const label = cell?.querySelector<HTMLElement>('.dg-name')+ const col = this.sheet.columns.find((c) => c.id === colId)+ if (!cell || !label || !col) return+ const input = document.createElement('input')+ input.className = 'dg-rename'+ input.value = col.name+ input.spellcheck = false+ input.setAttribute('aria-label', t('Column name'))+ label.replaceWith(input)+ input.focus()+ input.select()+ let done = false+ const finish = (write: boolean): void => {+ if (done) return+ done = true+ const v = input.value.trim()+ const sheetId = this.sheetId+ if (write && v && v !== col.name) {+ this.store.commit({ op: 'setColumn', sheet: sheetId, col: colId, patch: { name: v } })+ } else this.paint()+ this.focusGrid()+ }+ input.addEventListener('blur', () => finish(true))+ input.addEventListener('mousedown', (e) => e.stopPropagation())+ input.addEventListener('dblclick', (e) => e.stopPropagation())+ input.addEventListener('keydown', (e) => {+ // the grid owns bare keys otherwise, and a typed letter would land in a cell+ e.stopPropagation()+ if (e.key === 'Enter') { e.preventDefault(); finish(true) }+ else if (e.key === 'Escape') { e.preventDefault(); finish(false) }+ })+ }/*** Open a cell for editing.@@ -3583,12 +3786,204 @@ export class Grid {// the event reaches the document the "is something being edited?" guard// there no longer sees an editor — and Enter moved the cursor twice.e.stopPropagation()+ if (this.pointKey(e)) returnif (e.key === 'Enter') { e.preventDefault(); finish(true, e.shiftKey ? 'up' : 'down'); return }if (e.key === 'Tab') { e.preventDefault(); finish(true, e.shiftKey ? 'left' : 'right'); return }if (e.key === 'Escape') { e.preventDefault(); finish(false) }}}+ // --- POINT MODE ------------------------------------------------------------+ //+ // While a formula is being typed and the caret sits where an operand goes+ // (pointref.ts `acceptsRef`), clicking a cell or pressing an arrow key puts+ // that cell's ADDRESS into the formula instead of committing it — Excel's,+ // Sheets' and Numbers' most basic formula gesture. Shift (click or arrow)+ // grows it to a range, a drag draws one, and a second click REPLACES the+ // address just inserted rather than appending another. Any other key ends+ // the pointing and the address stays as typed text. Clicking another sheet's+ // tab inserts `Sheet!A1`, and the arrows then walk that sheet.+ //+ // The editor is never repainted while pointing — a paint rebuilds the rows+ // and would take the contentEditable cell with it — so the range highlight+ // is one box laid over the sizer by hand, and goes with the next paint.++ private point: {+ cell: HTMLElement+ /** where the inserted address sits in the editor's text */+ start: number+ end: number+ /** VISIBLE positions on this sheet; plain positions on `sheet` */+ anchor: Pos+ head: Pos+ sheet?: { id: string; name: string }+ } | null = null++ /** Is a formula edit waiting for a reference? (tabs.ts asks before switching) */+ isPointing(): boolean { return this.pointable() !== null }++ /** The editing cell, when its caret is somewhere an address can go. */+ private pointable(): HTMLElement | null {+ if (!this.editing && !this.cvEditing) return null+ const cell = this.table.querySelector<HTMLElement>('.dg-editing')+ if (!cell) return null+ const c = this.caretIn(cell)+ if (!c) return null+ const p = this.point+ if (p && p.cell === cell && c.end === p.end && (c.start === p.start || c.start === c.end)) return cell+ if (c.start !== c.end) return null+ return acceptsRef((cell.textContent ?? '').slice(0, c.start)) ? cell : null+ }++ /** The editor's selection as text offsets, or null when it is elsewhere. */+ private caretIn(cell: HTMLElement): { start: number; end: number } | null {+ const sel = getSelection()+ if (!sel || !sel.rangeCount) return null+ const r = sel.getRangeAt(0)+ if (!cell.contains(r.startContainer) || !cell.contains(r.endContainer)) return null+ const pre = document.createRange()+ pre.selectNodeContents(cell)+ pre.setEnd(r.startContainer, r.startOffset)+ const start = pre.toString().length+ pre.setEnd(r.endContainer, r.endOffset)+ return { start, end: pre.toString().length }+ }++ /** The address of a visible rectangle on THIS sheet, as a formula spells it. */+ private refFor(a: Pos, b: Pos): string {+ if (this.canvas) return refText(a, b)+ // A dataset formula addresses the FILE's rows and columns (cellformula.ts+ // `tableCellSource`): hidden columns count, and a sorted view's row 1 is+ // not the file's row 1. So the clicked visible cell is translated first.+ const s = this.sheet+ const vis = cols(s)+ const canon = (p: Pos): Pos => {+ const r = this.canonicalRow(p.row)+ const c = s.columns.indexOf(vis[p.col])+ return { row: r < 0 ? rowCount(s) : r, col: c < 0 ? p.col : c }+ }+ return refText(canon(a), canon(b))+ }++ /** Insert (or replace) the pointed-at address. False when nothing is pointable. */+ private pointTo(anchor: Pos, head: Pos, sheet?: { id: string; name: string }): boolean {+ const cell = this.pointable()+ if (!cell) return false+ const c = this.caretIn(cell)!+ const p = this.point && this.point.cell === cell && c.end === this.point.end ? this.point : null+ const start = p ? p.start : c.start+ const end = p ? p.end : c.end+ const ref = sheet ? refText(anchor, head, sheet.name) : this.refFor(anchor, head)+ const text = cell.textContent ?? ''+ cell.textContent = text.slice(0, start) + ref + text.slice(end)+ const at = start + ref.length+ const node = cell.firstChild ?? cell+ const range = document.createRange()+ range.setStart(node, at)+ range.collapse(true)+ getSelection()?.removeAllRanges()+ getSelection()?.addRange(range)+ this.point = { cell, start, end: at, anchor, head, sheet }+ this.drawPoint()+ return true+ }++ /** The coloured box over the pointed-at range (this sheet only). */+ private drawPoint(): void {+ this.table.querySelector('.dg-point')?.remove()+ const p = this.point+ if (!p || p.sheet) return+ const box: Box = {+ top: Math.min(p.anchor.row, p.head.row), bottom: Math.max(p.anchor.row, p.head.row),+ left: Math.min(p.anchor.col, p.head.col), right: Math.max(p.anchor.col, p.head.col),+ }+ const g = this.canvas ? this.canvasRect(box) : this.datasetRect(box)+ if (!g) return+ const el = document.createElement('div')+ el.className = 'dg-point'+ el.setAttribute('aria-hidden', 'true')+ el.style.cssText = `left:${g.left}px;top:${g.top}px;width:${g.width}px;height:${g.height}px`+ this.table.appendChild(el)+ }++ private endPoint(): void {+ if (!this.point) return+ this.point = null+ this.table.querySelector('.dg-point')?.remove()+ }++ /**+ * A key pressed inside a cell editor: an arrow while pointable points, and+ * anything else that is not a bare modifier ends the pointing. True when the+ * key was consumed.+ */+ private pointKey(e: KeyboardEvent): boolean {+ const step: Record<string, [number, number]> = {+ ArrowUp: [-1, 0], ArrowDown: [1, 0], ArrowLeft: [0, -1], ArrowRight: [0, 1],+ }+ const d = step[e.key]+ if (d && !e.metaKey && !e.ctrlKey && !e.altKey && this.pointable()) {+ e.preventDefault()+ const p = this.point+ const from = p ? p.head : { ...this.sel.cursor }+ const rows = p?.sheet ? Infinity : this.sel.rows+ const colsN = p?.sheet ? Infinity : this.sel.cols+ const next = {+ row: Math.max(0, Math.min(rows - 1, from.row + d[0])),+ col: Math.max(0, Math.min(colsN - 1, from.col + d[1])),+ }+ this.pointTo(e.shiftKey ? (p?.anchor ?? from) : next, next, p?.sheet)+ return true+ }+ if (!['Shift', 'Meta', 'Control', 'Alt'].includes(e.key)) this.endPoint()+ return false+ }++ /** A mousedown anywhere on the body, CAPTURE phase: point instead of commit. */+ private pointMouse(e: MouseEvent): void {+ if (e.button !== 0) return+ const editor = this.pointable()+ if (!editor) return+ const tgt = (e.target as HTMLElement | null)?.closest?.('.dg-cell[data-ci]') as HTMLElement | null+ const rowEl = tgt?.closest<HTMLElement>('.dg-row[data-row]')+ if (!tgt || !rowEl || tgt === editor || !this.table.contains(tgt)) return+ // preventDefault keeps focus (and the caret) in the editor: without it the+ // editor blurs, and blur is a commit.+ e.preventDefault()+ e.stopPropagation()+ const at = (el: HTMLElement, row: HTMLElement): Pos => ({ row: Number(row.dataset.row), col: Number(el.dataset.ci) })+ const pos = at(tgt, rowEl)+ const p = this.point+ const anchor = e.shiftKey && p && !p.sheet ? p.anchor : pos+ this.pointTo(anchor, pos)+ const move = (m: MouseEvent): void => {+ const x = (m.target as HTMLElement | null)?.closest?.('.dg-cell[data-ci]') as HTMLElement | null+ const xr = x?.closest<HTMLElement>('.dg-row[data-row]')+ if (!x || !xr || x === editor) return+ const h = at(x, xr)+ if (this.point && h.row === this.point.head.row && h.col === this.point.head.col) return+ this.pointTo(anchor, h)+ }+ const up = (): void => {+ document.removeEventListener('mousemove', move)+ document.removeEventListener('mouseup', up)+ }+ document.addEventListener('mousemove', move)+ document.addEventListener('mouseup', up)+ }++ /**+ * Another sheet's tab, clicked while pointing: `Sheet!A1` goes in and the+ * edit stays open on this sheet. True when the click was consumed.+ */+ pointToSheet(id: string): boolean {+ if (!this.pointable()) return false+ if (id === this.sheetId) return true+ const sh = this.store.doc.sheets.find((x) => x.id === id)+ if (!sh) return false+ return this.pointTo({ row: 0, col: 0 }, { row: 0, col: 0 }, { id, name: sh.name })+ }+/*** Keep keystrokes coming to the grid after an edit closes — and after Find* closes.diff --git a/dash/src/gridmenu.ts b/dash/src/gridmenu.tsindex d5d11232..9af44526 100644--- a/dash/src/gridmenu.ts+++ b/dash/src/gridmenu.ts@@ -41,12 +41,16 @@ import {insertRowsAt, deleteRowsAt, insertColumn, deleteColumn, setHidden,} from './rowcol.ts'import type { Store, Patch } from './store.ts'-import type { Column, TableSheet } from './model.ts'+import type { Column, ColumnType, TableSheet } from './model.ts'+import { TYPE_LABEL } from './format.ts'import type { Grid } from './grid.ts'import {blankCondFmtRule, condFmtPatch, describeCondFmtRule, readCondFmt, readOperand,} from './condfmtui.ts'+/** The types a new column can be given — the panel's list, in its order. */+const COLUMN_TYPES: ColumnType[] = ['text', 'number', 'money', 'percent', 'date', 'bool', 'enum']+/** Local, because gridmenu.ts must not import main.ts — see the note above. */function esc(s: string): string {return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')@@ -60,7 +64,10 @@ function esc(s: string): string {export interface MenuHooks {askForm(opts: {title: string- fields: Array<{ key: string; label: string; value?: string; placeholder?: string; mono?: boolean }>+ fields: Array<{+ key: string; label: string; value?: string; placeholder?: string; mono?: boolean+ options?: Array<readonly [string, string]>+ }>hint?: stringsubmit?: stringcheck?: (values: Record<string, string>) => string | null@@ -301,13 +308,20 @@ function askInsertColumn(store: Store, grid: Grid, at: number, hooks: MenuHooks)const sheet = grid.sheetvoid hooks.askForm({title: t('New column'),- fields: [{ key: 'name', label: t('Column name'), value: t('New column') }],+ // THE TYPE IS CHOSEN UP FRONT, as Airtable's add-field dialog does. A+ // name-only dialog made every new column Text and left the reader to find+ // the type chip afterwards to say what the column actually holds.+ fields: [+ { key: 'name', label: t('Column name'), value: t('New column') },+ { key: 'type', label: t('Type'), value: 'text', options: COLUMN_TYPES.map((tp) => [tp, t(TYPE_LABEL[tp])] as const) },+ ],submit: t('Insert'),}).then((got) => {if (!got) returnconst id = `c-${Math.floor(Date.now() % 1e8).toString(36)}`+ const type = (COLUMN_TYPES as string[]).includes(got.type) ? got.type as ColumnType : 'text'store.commit([- ...insertColumn(sheet, at, { id, name: got.name.trim() || t('New column'), type: 'text' }),+ ...insertColumn(sheet, at, { id, name: got.name.trim() || t('New column'), type }),...grid.shiftFormulas('col', at, 1),])})diff --git a/dash/src/main.ts b/dash/src/main.tsindex 49b9c052..86a2a92b 100644--- a/dash/src/main.ts+++ b/dash/src/main.ts@@ -36,7 +36,7 @@ import { APP_VERSION } from '../../kernel/src/update.ts'import { mountAbout, openAbout, rememberVersion, checkAtLaunch } from './about.ts'import { runSql, sqlRows } from './sql.ts'import { mountPanels, type Panels } from './panels.ts'-import { installStory } from './story.ts'+import { installStory, closeStoryEditor } from './story.ts'import { Dashboard } from './dashboard.ts'import { SyncSession } from './sync/session.ts'import { mountPeople } from './sync/people.ts'@@ -1249,6 +1249,27 @@ function boot(doc: DashDoc, repaired: number, frozen?: 'policy' | 'version', savcomputed: (id) => (id === grid.showingId() ? (grid.computed as Map<string, unknown[]>) : undefined),})+ // ESCAPE CLOSES THE STORY AND PIVOT PANELS (review 4.8), as it closes every+ // other dismissable surface in dash. One Escape closes ONE thing: anything+ // that already claimed this key (a menu, a dialog, Find, a cell editor, the+ // grid's copy marks) prevented or stopped it, and a dropdown still open is+ // shutMenus' to close. Registered before shutMenus' listener for that check.+ // The story first, then the pivot: the story editor floats above the panel.+ document.addEventListener('keydown', (e) => {+ if (e.key !== 'Escape' || e.defaultPrevented || e.metaKey || e.ctrlKey || e.altKey) return+ if (document.querySelector('.dx-dd.open, .dx-pop, .dx-ask-back, .dx-tab-menu, .ds-overlay')) return+ const tgt = e.target as HTMLElement | null+ const inStory = !!tgt?.closest?.('.ds-editor')+ const inPivot = !!pivotSpec && !!tgt && chartEl.contains(tgt)+ // a field elsewhere (the formula bar, a panel input) keeps its own Escape+ if (!inStory && !inPivot && tgt && (tgt.tagName === 'INPUT' || tgt.tagName === 'TEXTAREA' || tgt.tagName === 'SELECT' || tgt.isContentEditable)) return+ if (closeStoryEditor()) { e.preventDefault(); if (inStory) grid.focusGrid(); return }+ if (pivotSpec && !chartEl.hidden) {+ e.preventDefault()+ app.querySelector<HTMLElement>('.dx-chart-close')?.click()+ }+ })+const notes: Notice[] = []if (frozen) {notes.push({@@ -2438,6 +2459,8 @@ interface AskField {placeholder?: string/** formulas and ids are read character by character; prose is not */mono?: boolean+ /** a CHOICE rather than text: [value, label] pairs, drawn as a select */+ options?: Array<readonly [string, string]>}function askForm(opts: {@@ -2461,17 +2484,32 @@ function askForm(opts: {h.textContent = opts.titlecard.append(h)- const inputs: Record<string, HTMLInputElement> = {}+ const inputs: Record<string, HTMLInputElement | HTMLSelectElement> = {}for (const f of opts.fields) {const row = document.createElement('label')row.className = 'dx-ask-row'const lab = document.createElement('span')lab.textContent = f.label- const inp = document.createElement('input')- inp.className = `dx-ask-in${f.mono ? ' dx-ask-mono' : ''}`- inp.value = f.value ?? ''- if (f.placeholder) inp.placeholder = f.placeholder- inp.spellcheck = false+ let inp: HTMLInputElement | HTMLSelectElement+ if (f.options) {+ const sel = document.createElement('select')+ sel.className = 'dx-ask-in'+ for (const [v, l] of f.options) {+ const o = document.createElement('option')+ o.value = v+ o.textContent = l+ sel.append(o)+ }+ if (f.value !== undefined) sel.value = f.value+ inp = sel+ } else {+ const text = document.createElement('input')+ text.className = `dx-ask-in${f.mono ? ' dx-ask-mono' : ''}`+ text.value = f.value ?? ''+ if (f.placeholder) text.placeholder = f.placeholder+ text.spellcheck = false+ inp = text+ }row.append(lab, inp)card.append(row)inputs[f.key] = inp@@ -2532,6 +2570,7 @@ function askForm(opts: {document.addEventListener('keydown', onKey, true)for (const k of Object.keys(inputs)) inputs[k].addEventListener('input', validate)+ for (const k of Object.keys(inputs)) inputs[k].addEventListener('change', validate)cancel.addEventListener('click', () => done(null))ok.addEventListener('click', () => { if (validate()) done(values()) })// A click on the backdrop cancels; a click inside must not.@@ -2540,8 +2579,9 @@ function askForm(opts: {back.append(card)document.body.append(back)validate()- inputs[opts.fields[0].key]?.focus()- inputs[opts.fields[0].key]?.select()+ const first = inputs[opts.fields[0].key]+ first?.focus()+ if (first instanceof HTMLInputElement) first.select()})}diff --git a/dash/src/pointref.ts b/dash/src/pointref.tsnew file mode 100644index 00000000..01ac92b8--- /dev/null+++ b/dash/src/pointref.ts@@ -0,0 +1,53 @@+// SPDX-License-Identifier: MIT+// Copyright (c) 2026 The Bento authors+// POINT MODE: the text half of "click a cell to put its address in a formula".+//+// Typing `=` and clicking B4 inserts `B4` in Excel, Sheets and Numbers. It is+// the most basic formula gesture there is, and dash committed a literal "="+// instead and moved the cursor (UX review 2.4). The grid owns the gesture —+// which cell was clicked, the range highlight, keeping the editor open — and+// this module owns the two questions that are pure text, so a node rig can+// pin them without a browser:+//+// acceptsRef is the caret at a place a reference can go?+// refText what does the reference to this rectangle spell?+//+// A REFERENCE CAN GO where the formula is waiting for an operand: straight+// after the leading `=`, an operator, an opening bracket or an argument+// separator. Excel's rule, and the reason it is safe: after `=A1` the caret+// sits after an operand, so a click there must END the edit (commit and move)+// rather than splice a second address onto the first.++import { colToLetters, qualify } from './a1.ts'++/** The characters after which a formula is waiting for an operand. */+const OPERAND_NEXT = new Set(['=', '+', '-', '*', '/', '^', '&', '<', '>', '(', ',', ';', ':'])++/**+ * `before` is the editor's text up to the caret. True when it is a formula+ * (leading `=`) whose last non-blank character asks for an operand, and the+ * caret is not inside a string literal.+ */+export function acceptsRef(before: string): boolean {+ const s = before.replace(/^\s+/, '')+ if (!s.startsWith('=')) return false+ // An odd number of quotes means the caret is inside "a string", where a+ // comma is text, not an argument separator.+ if (((s.match(/"/g) ?? []).length & 1) === 1) return false+ const tail = s.replace(/\s+$/, '')+ return OPERAND_NEXT.has(tail[tail.length - 1])+}++export interface Pos { row: number; col: number }++/** `B4`, or `B4:D9` for a rectangle (normalised top-left first), qualified+ * with a sheet name when the reference points off the editing sheet. */+export function refText(a: Pos, b: Pos, sheet?: string): string {+ const top = Math.min(a.row, b.row), bottom = Math.max(a.row, b.row)+ const left = Math.min(a.col, b.col), right = Math.max(a.col, b.col)+ const one = (r: number, c: number): string => `${colToLetters(c)}${r + 1}`+ const ref = top === bottom && left === right+ ? one(top, left)+ : `${one(top, left)}:${one(bottom, right)}`+ return qualify(sheet, ref)+}diff --git a/dash/src/select.ts b/dash/src/select.tsindex cc5fd6fe..35ae4e54 100644--- a/dash/src/select.ts+++ b/dash/src/select.ts@@ -711,6 +711,32 @@ export class Selection {return this}+ /**+ * Shift-click a column header: the columns from the active range's anchor to+ * `c`, every row. The anchor column stays, as it does for a shift-click on a+ * cell, so A then shift-D is A:D and a second shift-B shrinks it to A:B.+ */+ extendCol(c: number): this {+ const { col } = this.clamp(0, c)+ this.active = {+ anchor: { row: 0, col: this.active.anchor.col },+ head: this.clamp(this.rows - 1, col),+ }+ if (!contains(this.active, this.cursor.row, this.cursor.col)) {+ this.cursor = { row: this.clamp(this.cursor.row, 0).row, col: this.active.anchor.col }+ }+ this.run = null+ return this+ }++ /** ⌘-click a column header: that whole column joins the selection. */+ addCol(c: number): this {+ const { col } = this.clamp(0, c)+ this.addRange({ anchor: { row: 0, col }, head: { row: this.rows - 1, col } })+ this.cursor = this.clamp(this.cursor.row, col)+ return this+ }+/*** ⌘-click a second block.*diff --git a/dash/src/story.ts b/dash/src/story.tsindex ae7f4110..24f0dfaa 100644--- a/dash/src/story.ts+++ b/dash/src/story.ts@@ -954,6 +954,14 @@ export function openStoryEditor(src: StorySource): HTMLElement {return el}+/** Close the story editor if it is open. True when there was one to close. */+export function closeStoryEditor(): boolean {+ const el = document.querySelector('.ds-editor')+ if (!el) return false+ el.remove()+ return true+}+/** Wire a topbar button. Returns a detach, for symmetry with the rest of dash. */export function installStory(src: StorySource & { button: HTMLElement }): () => void {const onClick = () => { openStoryEditor(src) }diff --git a/dash/src/styles.css b/dash/src/styles.cssindex 3d587a9c..fface7ba 100644--- a/dash/src/styles.css+++ b/dash/src/styles.css@@ -268,6 +268,7 @@and the range outline; --sel is the range fill. */--sel: #eef4ff;--sel-ring: #2563eb;+ --point: #7c3aed;/* ————— one scale, five surfaces —————The pivot, the dashboard, the story editor, the save menu and the About@@ -356,6 +357,7 @@/* ————— selection ————— */--sel: #16243c;--sel-ring: #3b82f6;+ --point: #a78bfa;/* the one themed token that is not a colour; was a media query */--bar-opacity: 0.45;@@ -1151,6 +1153,16 @@ html, body {.dg-h { display: flex; align-items: center; gap: 6px; font-weight: 600; }.dg-name { cursor: pointer; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; }.dg-name:hover { color: var(--accent); }+/* the column name, renamed in place (double-click). Sized to the slot the name+ occupies so the header does not jump; the field look comes from the shared+ input rule. */+.dg-rename {+ flex: 1 1 auto;+ min-width: 0;+ width: 100%;+ font: inherit;+ font-weight: 600;+}.dg-type {font: 500 10px/1.6 inherit;text-transform: uppercase;@@ -1516,6 +1528,38 @@ html, body {border-radius: 2px;z-index: 4;}+/* ————— copy marks (the "marching ants") —————+ What ⌘C / ⌘X took, outlined until Escape, the next edit or a paste. Four+ dashed edges drawn as background gradients so the dashes can MOVE (a CSS+ `border-style: dashed` cannot be animated). Same ring colour as the+ selection, so the two read as one family: solid = here, dashed = copied. */+.dg-ants {+ position: absolute;+ pointer-events: none;+ z-index: 5;+ margin: -1px 0 0 -1px;+ padding: 1px;+ --ant: var(--sel-ring);+ background:+ linear-gradient(90deg, var(--ant) 50%, transparent 0) repeat-x 0 0 / 8px 2px,+ linear-gradient(90deg, var(--ant) 50%, transparent 0) repeat-x 0 100% / 8px 2px,+ linear-gradient(0deg, var(--ant) 50%, transparent 0) repeat-y 0 0 / 2px 8px,+ linear-gradient(0deg, var(--ant) 50%, transparent 0) repeat-y 100% 0 / 2px 8px;+ animation: dg-ants 0.6s linear infinite;+}+@keyframes dg-ants {+ to { background-position: 8px 0, -8px 100%, 0 -8px, 100% 8px; }+}+@media (prefers-reduced-motion: reduce) { .dg-ants { animation: none; } }+/* ————— point mode: the range a formula is pointing at ————— */+.dg-point {+ position: absolute;+ pointer-events: none;+ z-index: 5;+ border: 2px dashed var(--point, #3b82f6);+ background: color-mix(in srgb, var(--point, #3b82f6) 12%, transparent);+ border-radius: 2px;+}.dg-handle {position: absolute;right: -4px;@@ -1609,12 +1653,25 @@ html, body {.dg-head-row { height: calc(var(--row-h) + 20px); }.dg-head-row .dg-cell { height: calc(var(--row-h) + 20px); line-height: normal; padding: 0; }.dg-h { flex-direction: column; align-items: stretch; gap: 0; }-/* --line, not --line-strong: this is a seam INSIDE the header, and at the- heavier weight the two-line header read as two stacked bands. */+/* THE LETTER STRIP IS LAID OUT IN FLOW: the letter at the left, the type chip+ at the right, each in its own space. It used to centre the letter and float+ the chip over the right half, which left the chip about 50px: enough for+ "PERCENT" only at 9px and 75% opacity, the least readable text in the app,+ and still 0px from the letter (the old note here filed exactly this). In+ flow the chip gets everything the letter does not use, so it reads at 11px,+ the floor slides holds its own small uppercase labels to (its section heads,+ .ed-help-sec h3), and the two can never paint over each other in any locale:+ the chip truncates with an ellipsis, the letter (the ADDRESS, how a person+ says which column they mean) never does. The full type is in `title`. */.dg-hstrip {position: relative;- display: block;+ display: flex;+ align-items: center;+ gap: 6px;height: 19px;+ padding: 0 3px 0 8px;+ /* --line, not --line-strong: a seam INSIDE the header; at the heavier+ weight the two-line header read as two stacked bands */border-bottom: 1px solid var(--line);background: var(--grid-head);}@@ -1626,49 +1683,18 @@ html, body {border-radius: 0;padding: 0;}-/* absolute, so the letter stays centred on the COLUMN rather than on whatever- space the badge leaves it */+.dg-hstrip .dg-letter { flex: none; text-align: left; }.dg-hstrip .dg-type {- position: absolute;- right: 3px;- top: 0;+ flex: 0 1 auto;+ min-width: 0;+ margin-left: auto;height: 19px;line-height: 17px;border: 0;background: transparent;- font-size: 9px;+ font-size: 11px;padding: 0 2px;- opacity: 0.75;- /* IT MUST NOT REACH THE LETTER. The badge is absolutely positioned (above)- so the letter stays centred on the COLUMN, which is right — but nothing- stopped a long type name running underneath it, and the two then paint on- top of each other: measured on the starter workbook, Italian renders "F"- and "Percentuale" overlapping by 8px, so neither the column letter nor the- type can be read. That is shipped today, not something a new locale- introduced; Portuguese only widens it from one column to three- ("Monetário", "Porcentagem"). English sits at exactly 0.0px clearance,- which is to say the layout had no margin at all and the first slightly- longer word was always going to collide.-- The letter is the ADDRESS — how a person says which column they mean — so- it is the one that must survive.-- THE CAP IS ENGLISH'S OWN WIDTH, and that is a deliberate ceiling rather- than a comfortable one. A cap generous enough to guarantee real clearance- (50% - 9px) also truncates English "Percent", which is a regression in the- shipped UI to fix a translation — not a trade worth making inside an i18n- change. So the rule is exactly: NO LOCALE MAY BE TIGHTER THAN ENGLISH. The- longer words truncate to the width English already occupies, and nothing- that fits today moves by a pixel.-- That leaves English itself still at ~0px clearance, which is a real- finding and not one CSS can answer: at 109px the strip simply does not- have room for a centred letter and the word "Percent". Fixing it properly- means shorter labels in the badge or a strip that lays the two out in- flow, and both are design calls about the header rather than about- Portuguese. Filed, not smuggled in here. The full name is already in- `title`. */- max-width: calc(50% - 2px);+ letter-spacing: 0.02em;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;diff --git a/dash/src/tabs.ts b/dash/src/tabs.tsindex db1d878e..8620950c 100644--- a/dash/src/tabs.ts+++ b/dash/src/tabs.ts@@ -827,6 +827,19 @@ export function mountTabs(host: TabsHost): Tabs {// --- switching ---------------------------------------------------------------+ // POINT MODE: a tab clicked while a formula is waiting for a reference puts+ // `Sheet!A1` into the formula instead of switching sheets (grid.ts+ // `pointToSheet`). CAPTURE, and the mousedown's default prevented, because+ // the focus leaving the cell editor is a blur and a blur commits the edit.+ strip.addEventListener('mousedown', (e) => {+ if (e.button !== 0) return+ const el = tabAt(e)+ if (!el?.dataset.sheet || !grid.isPointing()) return+ e.preventDefault()+ e.stopPropagation()+ if (grid.pointToSheet(el.dataset.sheet)) suppressClick = true+ }, true)+strip.addEventListener('click', (e) => {if (suppressClick) { suppressClick = false; return }const el = tabAt(e)diff --git a/docs/DECISIONS.md b/docs/DECISIONS.mdindex 8aef1e7c..b4a5307e 100644--- a/docs/DECISIONS.md+++ b/docs/DECISIONS.md@@ -11544,3 +11544,16 @@ installed jsdom.end, including the encrypted-title rig with jsdom hidden, which must turn thestep red. It also checks that every allowlist entry's rig still prints itsline, and that every rig step in every CI file runs through the wrapper.++## 2026-10-20 — dash: a column header click selects; sorting is a command++In dash a click on a column header (dataset name or spreadsheet letter) selects+the column, shift extends, ⌘/Ctrl adds, and it never sorts. Excel, Sheets,+Numbers and Airtable all do this, and the old click-to-sort left the selection+on its screen rectangle, which after the sort held different records. Sorting+lives in the header's ▾ menu and the right-click menu. Double-clicking a+dataset column's name renames it in place. A sort or filter now carries the+selection by ROW identity: whole columns stay whole, single-row ranges move+with their row, and a taller block collapses to the cursor cell (its rows no+longer sit together). Point mode inserts a dataset reference in the FILE's+row and column numbering (`tableCellSource`), not the sorted view's.diff --git a/scripts/test-dash-gestures-browser.mjs b/scripts/test-dash-gestures-browser.mjsnew file mode 100644index 00000000..b324ee88--- /dev/null+++ b/scripts/test-dash-gestures-browser.mjs@@ -0,0 +1,366 @@+// SPDX-License-Identifier: MIT+// Copyright (c) 2026 The Bento authors+// The grid's core gestures, driven with a real mouse and keyboard.+//+// npm run build:single --prefix dash && node scripts/test-dash-gestures-browser.mjs+//+// WHAT THIS PROVES, in the packaged document on the starter workbook:+// 1. a column header click SELECTS the column (shift extends, ⌘ adds) and+// never sorts; a right-click opens the column menu without sorting; the+// spreadsheet's column letters select the same way;+// 2. sorting still works from the header ▾ menu, and the selected cell+// follows its ROW through the sort instead of staying on the screen+// position (which then holds a different record);+// 3. double-clicking a column name renames it in place: Enter commits one+// undo step, Escape changes nothing;+// 4. + Add a column asks for the type up front, and the type chip on the+// header reads at 11px or more without touching the column letter;+// 5. ⌘C / ⌘X draw marching ants over what was copied, until Escape, the next+// edit, or a paste;+// 6. POINT MODE: after `=`, an operator, `(` or `,`, clicking a cell or+// pressing an arrow inserts its address (shift and drag make a range,+// with a highlight), another sheet's tab inserts `Sheet!A1`, Enter+// commits — on a spreadsheet AND in a dataset per-cell formula, where a+// sorted view still writes the FILE's row;+// 7. Escape closes the Story and Pivot panels.+// Every row has a control showing the path ran (the selection moved, the menu+// opened, the click still commits where no reference can go, …).+// DASH_SHELL=<path> runs it against another build (the fails-on-old-code check).+const { chromium } = await import(process.env.PLAYWRIGHT_MODULE || 'playwright')++let checks = 0+let failures = 0+function ok(cond, msg) {+ checks+++ if (!cond) { failures++; console.log(` FAIL ${msg}`) } else console.log(` ok ${msg}`)+}++const SHELL = process.env.DASH_SHELL+ ? new URL(`file://${process.env.DASH_SHELL}`).href+ : new URL('../dash/dist-single/Bento_Dash.bento.html', import.meta.url).href+const MOD = process.platform === 'darwin' ? 'Meta' : 'Control'++const browser = await chromium.launch(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {})+const errors = []++async function fresh() {+ const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } })+ await ctx.grantPermissions(['clipboard-read', 'clipboard-write']).catch(() => {})+ const page = await ctx.newPage()+ page.on('pageerror', (e) => errors.push(e.message))+ await page.goto(SHELL)+ await page.waitForSelector('.dg-h[data-col]')+ await page.waitForTimeout(300)+ return { ctx, page }+}++const cellSel = (r, c) => `.dg-sizer .dg-row[data-row="${r}"] .dg-cell[data-ci="${c}"]`+async function center(page, sel) {+ const b = await page.locator(sel).first().boundingBox()+ if (!b) throw new Error(`no box for ${sel}`)+ return { x: b.x + b.width / 2, y: b.y + b.height / 2 }+}+async function click(page, sel, opts = {}) {+ const p = await center(page, sel)+ if (opts.modifiers) for (const m of opts.modifiers) await page.keyboard.down(m)+ await page.mouse.click(p.x, p.y, { button: opts.button ?? 'left', clickCount: opts.clickCount ?? 1 })+ if (opts.modifiers) for (const m of opts.modifiers) await page.keyboard.up(m)+ await page.waitForTimeout(60)+}+async function dblclick(page, sel) {+ const p = await center(page, sel)+ await page.mouse.dblclick(p.x, p.y)+ await page.waitForTimeout(80)+}+const sorts = (page) => page.$$eval('.dg-h[data-col]', (els) => els.map((e) => e.getAttribute('aria-sort')))+const onCols = (page) => page.$$eval('.dg-h.dg-h-on', (els) => els.map((e) => Number(e.dataset.ci)))+const colOf = (page, name) => page.evaluate((n) => window.bento.doc.sheets[0].columns.find((c) => c.name === n)?.id, name)+const editorText = (page) => page.evaluate(() => document.querySelector('.dg-editing')?.textContent ?? null)+const selRows = (page, ci) => page.$$eval(`.dg-sizer .dg-row[data-rid] .dg-cell[data-ci="${ci}"]`,+ (els) => els.filter((e) => e.classList.contains('dg-sel')).length)+const dataRows = (page) => page.$$eval('.dg-sizer .dg-row[data-rid]', (els) => els.length)+const cursorText = (page) => page.evaluate(() => document.querySelector('.dg-sizer .dg-cursor')?.textContent ?? null)++// ── 1. header click selects, never sorts ─────────────────────────────────────+console.log('header click')+{+ const { ctx, page } = await fresh()+ const rows = await dataRows(page)+ ok((await sorts(page)).every((s) => s === 'none'), 'control: nothing is sorted at boot')+ await click(page, '.dg-h[data-ci="1"] .dg-name')+ ok((await sorts(page)).every((s) => s === 'none'), 'clicking the Owner name does not sort')+ ok(!/Sorted/.test(await page.evaluate(() => document.querySelector('.dg-a11y')?.textContent ?? '')), 'the view status says nothing about a sort')+ ok(JSON.stringify(await onCols(page)) === '[1]', `the click selects column B (lit: ${JSON.stringify(await onCols(page))})`)+ ok(await selRows(page, 1) === rows, `every row of column B is selected (${await selRows(page, 1)}/${rows})`)+ await click(page, '.dg-h[data-ci="2"] .dg-letter', { modifiers: ['Shift'] })+ ok(JSON.stringify(await onCols(page)) === '[1,2]', `shift-click extends to B:C (${JSON.stringify(await onCols(page))})`)+ await click(page, '.dg-h[data-ci="4"]', { modifiers: [MOD] })+ const lit = await onCols(page)+ ok(lit.includes(4) && lit.includes(1) && !lit.includes(3), `⌘-click adds column E without D (${JSON.stringify(lit)})`)+ ok(await selRows(page, 4) === rows && await selRows(page, 3) === 0, 'E is wholly selected, D not at all')+ // right-click: the column menu, still no sort+ await click(page, '.dg-h[data-ci="2"] .dg-name', { button: 'right' })+ ok(await page.$('.dx-pop') !== null, 'control: right-click opened the column menu')+ ok((await sorts(page)).every((s) => s === 'none'), 'right-click does not sort')+ await page.keyboard.press('Escape')+ // double-click the name: rename, not sort-twice+ await dblclick(page, '.dg-h[data-ci="1"] .dg-name')+ ok((await sorts(page)).every((s) => s === 'none'), 'double-click does not sort')+ ok(await page.$('.dg-h .dg-rename') !== null, 'double-click opens an in-place name field')+ await page.keyboard.press(`${MOD}+a`)+ await page.keyboard.type('Seller')+ await page.keyboard.press('Enter')+ await page.waitForTimeout(80)+ const names = () => page.evaluate(() => window.bento.doc.sheets[0].columns.map((c) => c.name))+ ok((await names())[1] === 'Seller', `Enter commits the new name (${(await names())[1]})`)+ ok(await page.$eval('.dg-h[data-ci="1"] .dg-name', (e) => e.textContent.trim()) === 'Seller', 'the header shows it')+ await page.evaluate(() => window.bento.undo())+ await page.waitForTimeout(60)+ ok((await names())[1] === 'Owner', 'ONE undo puts the old name back')+ await dblclick(page, '.dg-h[data-ci="1"] .dg-name')+ await page.keyboard.type('Nope')+ await page.keyboard.press('Escape')+ await page.waitForTimeout(60)+ ok((await names())[1] === 'Owner' && await page.$('.dg-rename') === null, 'Escape cancels the rename')+ // the spreadsheet's letters select the same way+ await click(page, '.dx-tab[data-sheet="sheet-scratch"]')+ await page.waitForSelector('.dg-canvas .dg-h.dg-ch')+ await click(page, '.dg-ch[data-ci="2"]')+ ok(JSON.stringify(await onCols(page)) === '[2]', `spreadsheet: clicking C selects column C (${JSON.stringify(await onCols(page))})`)+ await click(page, '.dg-ch[data-ci="4"]', { modifiers: ['Shift'] })+ ok(JSON.stringify(await onCols(page)) === '[2,3,4]', `spreadsheet: shift-click extends to C:E (${JSON.stringify(await onCols(page))})`)+ await ctx.close()+}++// ── 2. sorting from ▾, and the selection follows its row ─────────────────────+console.log('sort from the menu')+{+ const { ctx, page } = await fresh()+ // East / Lee / £4,300 sits on visible row 3+ await click(page, cellSel(3, 3))+ const before = await cursorText(page)+ const ownerId = await colOf(page, 'Owner')+ await click(page, `.dg-filter[data-filter="${ownerId}"]`)+ await click(page, '.dx-pop button[data-a="asc"]')+ await page.keyboard.press('Escape')+ await page.waitForTimeout(80)+ ok((await sorts(page))[1] === 'ascending', 'Sort A → Z in the ▾ menu sorts the column')+ const at3 = await page.$eval(cellSel(3, 3), (e) => e.textContent)+ ok(at3 !== before, `control: the sort moved a different record onto row 4 (${at3} ≠ ${before})`)+ ok(await cursorText(page) === before, `the selected cell followed its row (${await cursorText(page)} = ${before})`)+ // and a selected whole column stays the whole column+ await click(page, '.dg-h[data-ci="0"]')+ await click(page, `.dg-filter[data-filter="${await colOf(page, 'Value')}"]`)+ await click(page, '.dx-pop button[data-a="desc"]')+ await page.keyboard.press('Escape')+ await page.waitForTimeout(80)+ ok(JSON.stringify(await onCols(page)) === '[0]' && await selRows(page, 0) === await dataRows(page), 'a selected column stays selected through a sort')+ await ctx.close()+}++// ── 3. add a column with its type; the type chip is readable ─────────────────+console.log('add column + type chip')+{+ const { ctx, page } = await fresh()+ const chip = await page.$$eval('.dg-h[data-col]', (els) => els.map((h) => {+ const t = h.querySelector('.dg-type'); const l = h.querySelector('.dg-letter')+ const a = t.getBoundingClientRect(); const b = l.getBoundingClientRect()+ const s = getComputedStyle(t)+ return { size: parseFloat(s.fontSize), op: parseFloat(s.opacity), gap: a.left - b.right, clipped: t.scrollWidth > t.clientWidth + 0.5, text: t.textContent }+ }))+ ok(chip.length === 7, 'control: seven type chips measured')+ ok(chip.every((c) => c.size >= 11), `every type chip is at least 11px (${[...new Set(chip.map((c) => c.size))].join(',')})`)+ ok(chip.every((c) => c.op >= 0.99), 'at full opacity')+ ok(chip.every((c) => c.gap >= 4), `none comes within 4px of its letter (min ${Math.min(...chip.map((c) => c.gap)).toFixed(1)})`)+ ok(chip.every((c) => !c.clipped), `none is truncated in English (${chip.filter((c) => c.clipped).map((c) => c.text).join(',') || 'none'})`)+ await click(page, '.dg-add-col')+ await page.waitForSelector('.dx-ask')+ const sel = await page.$('.dx-ask select')+ ok(sel !== null, 'the New column dialog has a type picker')+ if (sel) {+ const opts = await sel.$$eval('option', (os) => os.map((o) => o.value))+ ok(opts.length === 7 && opts.includes('money') && opts.includes('date'), `it offers every column type (${opts.join(',')})`)+ const name = await page.$('.dx-ask input.dx-ask-in')+ await name.fill('Budget')+ await sel.selectOption('money')+ await page.click('.dx-ask-go')+ await page.waitForTimeout(80)+ const col = await page.evaluate(() => window.bento.doc.sheets[0].columns.at(-1))+ ok(col?.name === 'Budget' && col?.type === 'money', `the new column is created with the chosen type (${col?.name}:${col?.type})`)+ }+ await ctx.close()+}++// ── 4. copy marks ────────────────────────────────────────────────────────────+console.log('copy marks')+{+ const { ctx, page } = await fresh()+ await ctx.grantPermissions(['clipboard-read', 'clipboard-write']).catch(() => {})+ await click(page, cellSel(1, 0))+ await click(page, cellSel(2, 1), { modifiers: ['Shift'] })+ ok(await page.$('.dg-ants') === null, 'control: no ants before copying')+ await page.keyboard.press(`${MOD}+c`)+ await page.waitForTimeout(60)+ const ants = await page.$('.dg-ants')+ ok(ants !== null, '⌘C draws the marching ants')+ if (ants) {+ const a = await ants.boundingBox(); const o = await (await page.$('.dg-outline')).boundingBox()+ ok(Math.abs(a.x - o.x) <= 2 && Math.abs(a.width - o.width) <= 3 && Math.abs(a.height - o.height) <= 3,+ `over exactly the copied range (${a.width.toFixed(0)}×${a.height.toFixed(0)} vs ${o.width.toFixed(0)}×${o.height.toFixed(0)})`)+ }+ await click(page, cellSel(5, 2))+ ok(await page.$('.dg-ants') !== null, 'moving the selection keeps them')+ await page.keyboard.press('Escape')+ ok(await page.$('.dg-ants') === null, 'Escape clears them')+ await click(page, cellSel(1, 0))+ await page.keyboard.press(`${MOD}+c`)+ await click(page, cellSel(6, 1))+ await page.keyboard.type('Late')+ await page.keyboard.press('Enter')+ await page.waitForTimeout(60)+ ok(await page.$eval(cellSel(6, 1), (e) => e.textContent) === 'Late', 'control: the edit was written')+ ok(await page.$('.dg-ants') === null, 'the next edit clears them')+ await click(page, cellSel(1, 0))+ await page.keyboard.press(`${MOD}+c`)+ ok(await page.$('.dg-ants') !== null, 'control: copied again')+ await click(page, cellSel(7, 2))+ await page.evaluate(() => {+ const dt = new DataTransfer(); dt.setData('text/plain', 'South')+ ;(document.activeElement ?? document.body).dispatchEvent(new ClipboardEvent('paste', { clipboardData: dt, bubbles: true }))+ })+ await page.waitForTimeout(60)+ const pasted = await page.$eval(cellSel(7, 2), (e) => e.textContent)+ ok(pasted.startsWith('South'), `control: the paste landed (${pasted})`)+ ok(await page.$('.dg-ants') === null, 'a paste clears them')+ await click(page, cellSel(2, 0))+ await page.keyboard.press(`${MOD}+x`)+ await page.waitForTimeout(60)+ ok(await page.$('.dg-ants') !== null, '⌘X draws them too (after the cut has cleared the cell)')+ await ctx.close()+}++// ── 5. point mode ────────────────────────────────────────────────────────────+console.log('point mode')+{+ const { ctx, page } = await fresh()+ await click(page, '.dx-tab[data-sheet="sheet-scratch"]')+ await page.waitForSelector('.dg-canvas .dg-sizer .dg-row')+ // numbers to point at: C3:C5 = 1, 2, 3+ await click(page, cellSel(2, 2))+ for (const n of ['1', '2', '3']) { await page.keyboard.type(n); await page.keyboard.press('Enter') }+ const scratch = () => page.evaluate(() => window.bento.doc.sheets.find((s) => s.id === 'sheet-scratch').cells)+ await click(page, cellSel(0, 0))+ await page.keyboard.type('=SUM(')+ await click(page, cellSel(2, 2))+ ok(await editorText(page) === '=SUM(C3', `clicking C3 inserts its address (${await editorText(page)})`)+ ok(await page.$('.dg-point') !== null, 'and highlights it')+ await click(page, cellSel(4, 2), { modifiers: ['Shift'] })+ ok(await editorText(page) === '=SUM(C3:C5', `shift-click makes it a range (${await editorText(page)})`)+ const hl = await page.$('.dg-point')+ if (hl) {+ const h = await hl.boundingBox(); const top = await page.locator(cellSel(2, 2)).boundingBox()+ ok(Math.abs(h.y - top.y) <= 3 && h.height >= top.height * 3 - 4, `the highlight covers C3:C5 (${h.height.toFixed(0)}px tall)`)+ }+ await page.keyboard.type(')')+ await page.keyboard.press('Enter')+ await page.waitForTimeout(80)+ ok((await scratch())['0,0']?.f === '=SUM(C3:C5)' || Object.values(await scratch()).some((c) => c?.f === '=SUM(C3:C5)'),+ 'Enter commits =SUM(C3:C5)')+ ok(await page.$eval(cellSel(0, 0), (e) => e.textContent) === '6', `which computes 6 (${await page.$eval(cellSel(0, 0), (e) => e.textContent)})`)+ // arrows: from the editing cell, shift to extend+ await click(page, cellSel(0, 1))+ await page.keyboard.type('=')+ await page.keyboard.press('ArrowDown')+ ok(await editorText(page) === '=B2', `an arrow points at the cell below (${await editorText(page)})`)+ await page.keyboard.press('ArrowRight')+ ok(await editorText(page) === '=C2', `a second arrow MOVES the reference rather than adding one (${await editorText(page)})`)+ await page.keyboard.press('Shift+ArrowDown')+ await page.keyboard.press('Shift+ArrowDown')+ ok(await editorText(page) === '=C2:C4', `shift+arrow extends it (${await editorText(page)})`)+ await page.keyboard.type('*2')+ await page.keyboard.press('ArrowLeft')+ ok(await editorText(page) === '=C2:C4*2', `after an operand an arrow is just the caret again (${await editorText(page)})`)+ await page.keyboard.press('Escape')+ // drag draws a range+ await click(page, cellSel(1, 4))+ await page.keyboard.type('=')+ const a = await center(page, cellSel(2, 2)); const b = await center(page, cellSel(4, 3))+ await page.mouse.move(a.x, a.y); await page.mouse.down(); await page.mouse.move(b.x, b.y, { steps: 6 }); await page.mouse.up()+ ok(await editorText(page) === '=C3:D5', `a drag points at a range (${await editorText(page)})`)+ await page.keyboard.press('Escape')+ // control: where no reference can go, a click still commits and moves+ await click(page, cellSel(6, 0))+ await page.keyboard.type('=C3')+ await click(page, cellSel(8, 3))+ ok(await editorText(page) === null, 'control: after an operand, a click commits the edit')+ ok(Object.values(await scratch()).some((c) => c?.f === '=C3'), 'control: and =C3 was written')+ // another sheet's tab+ await click(page, cellSel(7, 0))+ await page.keyboard.type('=')+ await click(page, '.dx-tab[data-sheet="sheet-pipeline"]')+ ok(await page.evaluate(() => document.querySelector('.dx-tab.active')?.dataset.sheet) === 'sheet-scratch', 'clicking the Pipeline tab does not leave the sheet')+ ok(await editorText(page) === '=Pipeline!A1', `it inserts Pipeline!A1 (${await editorText(page)})`)+ for (let i = 0; i < 3; i++) await page.keyboard.press('ArrowRight')+ await page.keyboard.press('ArrowDown')+ ok(await editorText(page) === '=Pipeline!D2', `arrows walk the other sheet (${await editorText(page)})`)+ await page.keyboard.press('Enter')+ await page.waitForTimeout(80)+ ok(/8,?200/.test(await page.$eval(cellSel(7, 0), (e) => e.textContent)), `=Pipeline!D2 computes £8,200's value (${await page.$eval(cellSel(7, 0), (e) => e.textContent)})`)+ await ctx.close()+}++console.log('point mode on a dataset')+{+ const { ctx, page } = await fresh()+ const stage = await colOf(page, 'Stage')+ const over = () => page.evaluate((id) => Object.entries(window.bento.doc.sheets[0].cells ?? {})+ .filter(([k, v]) => k.startsWith(id + ':') && v?.f).map(([, v]) => v.f), stage)+ await click(page, cellSel(0, 2))+ await page.keyboard.type('=')+ await click(page, cellSel(1, 3))+ ok(await editorText(page) === '=D2', `a dataset cell points too (${await editorText(page)})`)+ await page.keyboard.press('Enter')+ await page.waitForTimeout(80)+ ok((await over()).includes('=D2'), 'Enter writes the per-cell formula =D2')+ // sorted by Value ▼: the top row is the file's row 6 (£22,750)+ await click(page, `.dg-filter[data-filter="${await colOf(page, 'Value')}"]`)+ await click(page, '.dx-pop button[data-a="desc"]')+ await page.keyboard.press('Escape')+ await page.waitForTimeout(80)+ ok(/22,750/.test(await page.$eval(cellSel(0, 3), (e) => e.textContent)), 'control: £22,750 is on top after the sort')+ await click(page, cellSel(2, 2))+ await page.keyboard.type('=')+ await click(page, cellSel(0, 3))+ ok(await editorText(page) === '=D6', `pointing in a sorted view writes the FILE's row (${await editorText(page)})`)+ await page.keyboard.press('Escape')+ await ctx.close()+}++// ── 6. Escape closes Story and Pivot ─────────────────────────────────────────+console.log('Escape closes panels')+{+ const { ctx, page } = await fresh()+ await click(page, cellSel(1, 1))+ await click(page, '[data-act="story"]')+ ok(await page.$('.ds-editor') !== null, 'control: the Story panel opened')+ await page.keyboard.press(`${MOD}+c`)+ await page.keyboard.press('Escape')+ ok(await page.$('.dg-ants') === null && await page.$('.ds-editor') !== null, 'one Escape closes one thing: the copy marks first')+ await page.keyboard.press('Escape')+ ok(await page.$('.ds-editor') === null, 'Escape closes the Story panel')+ await click(page, '.ds-editor', { modifiers: [] }).catch(() => {})+ await click(page, '[data-act="pivot"]')+ await page.waitForTimeout(150)+ const shown = () => page.evaluate(() => { const el = document.querySelector('.dx-chart-close')?.closest('[hidden], .dx-chart, aside, section'); return !!document.querySelector('.dx-chart-close') && document.querySelector('.dx-chart-close').offsetParent !== null })+ ok(await shown(), 'control: the Pivot panel opened')+ await click(page, cellSel(2, 1))+ await page.keyboard.press('Escape')+ await page.waitForTimeout(60)+ ok(!(await shown()), 'Escape closes the Pivot panel')+ await ctx.close()+}++await browser.close()+ok(errors.length === 0, `no page errors (${errors.join(' | ') || 'none'})`)+console.log(`\n${checks - failures}/${checks} checks passed`)+process.exit(failures ? 1 : 0)