Skip to content

fix(grid): make Tab move the edit to the next cell - #555

Merged
EVWorth merged 1 commit into
mainfrom
fix/grid-tab-focus
Sep 7, 2026
Merged

EVWorth merged 1 commit into
mainfrom
fix/grid-tab-focus

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Closes #408 — the last bug in results/grid.

What was wrong

Tab committed the cell and then wrote the next position into a ref:

editingCellRef.current = { rowIndex: rowIdx, colIndex: nextCol };

Nothing ever read it. The cell left edit mode and focus went wherever the browser sends it next in document order — past the rest of the row, out of the table, onto a footer button.

It couldn't have worked from there. Whether a cell is being edited was the cell's own state, and a cell cannot put a different cell into edit mode.

The fix

The state moves up to the grid, and EditableCell becomes controlled — editing and onEditingChange come from the parent, which knows where the edit should go next. Pending insert rows use negative row indices, so one piece of state covers both grids and the two can't collide.

nextEditableCell holds the only part with real logic: past the last column the edit carries on into the next row, before the first it goes back to the previous, and at either end of the grid it stops rather than wrapping round to a cell the user isn't looking at.

One thing worth pointing at: editingCell had to go into the column memo's dependency list. Without it the memoised cell renderers keep the old value closed over and the edit never appears to move — the same shape of bug as the one being fixed, one level up.

Tests

Eight on the navigation logic, five on the grid. Four of the five fail against the previous version.

EditableCell's own 19 tests now render it through a small harness that plays the grid's part, so they still exercise double-click-to-edit, Escape and blur rather than being rewritten around the new props.

A slip worth recording: the first version of that harness rendered itself — a regex meant to update the call sites rewrote the harness's own body too — and the suite exhausted the heap instead of failing, which took a moment to read. Caught and fixed before anything else ran.

1784 unit + 303 browser green, tsc/dprint/eslint clean.

🤖 Generated with Claude Code

Closes #408.

Tab committed the cell and then wrote the next position into a ref:

    editingCellRef.current = { rowIndex: rowIdx, colIndex: nextCol };

Nothing ever read it. The cell left edit mode, and focus went wherever the
browser sends it next in document order — past the rest of the row, out of
the table, onto a footer button.

It could not have worked from there. Whether a cell is being edited was the
cell's own state, and a cell cannot put a different cell into edit mode. So
the state moves up to the grid, and EditableCell becomes controlled:
`editing` and `onEditingChange` come from the parent, which knows where the
edit should go next. Pending insert rows use negative row indices, so one
piece of state covers both grids and the two cannot collide.

nextEditableCell holds the only part with any logic. Past the last column
the edit carries on into the next row; before the first, back into the
previous. At either end of the grid it stops rather than wrapping round to a
cell the user is not looking at.

editingCell is in the column memo's dependencies. Without it the memoised
cell renderers would keep the old value closed over and the edit would never
appear to move — the same shape of bug as the one being fixed.

Eight unit tests on the navigation, five on the grid; four of the five fail
against the previous version.

EditableCell's own tests now render it through a small harness that plays
the grid's part, so they still exercise double-click-to-edit and Escape
rather than being rewritten around the new props. Worth saying that the
first version of that harness rendered itself — a regex meant to update the
call sites rewrote the harness's own body too — and the suite ran out of
memory rather than failing, which took a moment to read.

Co-Authored-By: Claude Opus 5 <[email protected]>
@EVWorth
EVWorth merged commit 6e43343 into main Sep 7, 2026
10 checks passed
@EVWorth
EVWorth deleted the fix/grid-tab-focus branch September 7, 2026 17:00
EVWorth added a commit that referenced this pull request Sep 9, 2026
…ty from absent (#581)

Closes #366, #578.

## A file too large to show now says so (#366)

read_file_contents read whatever it was given. Everything downstream — the
Rust string, the JavaScript copy of it, the parsed rows — is held at once, so
a multi-gigabyte CSV took the renderer down before the user saw anything.

It now checks the size from the file's metadata and refuses before reading a
byte, naming the size, the limit and what to do instead. The cap is 256 MB,
chosen from what the pipeline survives rather than from disk.

The issue asks for streaming, which is the right long-term answer and a much
larger change: chunked reads, a chunked parse, and batched inserts driven by
the chunks. Refusing is not that. It is the part that stops the app dying,
and it is worth having whether or not streaming is built later.

Applied in the command rather than the dialog, so restore gets it too — it
reads whole files the same way.

## The file decides empty from absent (#578)

Every empty cell became SQL NULL. CSV distinguishes `,,` from `,"",` but
parseCSVLine discarded the quoting before anyone could act on it, so a NOT
NULL column rejected a row the user considered valid and a nullable one
silently stored NULL where the file said "".

The parser now reports which cells were written bare, alongside the rows
rather than changing their type, so every existing caller reads them
unchanged. A bare empty becomes NULL and a quoted one stays "". A row shorter
than its header is absent rather than empty, which is the same reading.

generateBatchInsert takes the flags as an optional argument and behaves as it
did without them.

## Two found while wiring it

setCsvBareEmpty could be handed undefined by a caller predating the field,
and the component then threw on .map when the import ran. Defaulted.

The import callback used the new state without listing it as a dependency, so
it would have closed over an empty array and treated every cell as absent —
the same shape as the grid's memo in #555. Caught by lint, which is what that
warning is for.

Three Rust tests on the limit, four on the parser, three on the generator.

Co-authored-by: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1] [bug] Tab in editable cell doesn't move focus — editingCellRef never read

1 participant