Web: a repaint never wipes an open cell editor
#72 web canary: Bold then typing at once in Chromium saved an empty cell. The editor the key opened was repainted away by the format's response (setValueFromCoords on its td), and closing it then read nothing. A batch now leaves the edited cell's td alone (its value comes back with the edit's own response); its style still repaints. Covered by TestFirstKeystrokeAfterLeavingTheGrid's "typing at once" case, in the next commit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+9
−9
internal/sheets/static/grid.js+9 −9
diff --git a/internal/sheets/static/grid.js b/internal/sheets/static/grid.js| index 7769f65..157411f 100644 |
| --- a/internal/sheets/static/grid.js |
| +++ b/internal/sheets/static/grid.js |
| @@ -2,15 +2,12 @@ |
| * |
| * It paints strings the server computed and never evaluates a formula |
| * itself. parseFormulas is off below, deliberately: our engine and |
| - * Jspreadsheet's would disagree on the first SUM(1,2,"3") — the |
| - * divergence the formula corpus already documents — and the |
| - * disagreement would be invisible, because both would look like a |
| - * number in a cell. |
| + * Jspreadsheet's would disagree on the first SUM(1,2,"3"), and invisibly: |
| + * both would look like a number in a cell. |
| * |
| - * Cell data holds DISPLAY strings; the raw input lives in a side map. |
| - * That way the grid shows 42 and the formula bar shows =6*7, which is |
| - * what a spreadsheet does. The alternative — raw in the data — shows |
| - * you =6*7 in every cell and is not a spreadsheet. |
| + * Cell data holds DISPLAY strings; the raw input lives in a side map, |
| + * so the grid shows 42 and the formula bar =6*7, as a spreadsheet does; |
| + * raw in the data would show =6*7 in every cell. |
| * |
| * The chrome above and below the grid is not wired here. This module |
| * publishes window.SheetsGrid and menubar.js and commands.js build on |
| @@ -100,7 +97,10 @@ |
| payload.cells.forEach(function (cell) { |
| if (cell.r >= rows || cell.c >= cols) return; |
| meta[key(cell.r, cell.c)] = { raw: cell.raw || '', f: cell.f, n: cell.n }; |
| - ws.setValueFromCoords(cell.c, cell.r, cell.display, true); |
| + /* Never under an open editor: setting its td would wipe the edit, |
| + * and closing it then would save an empty cell. */ |
| + var ed = ws.edition; |
| + if (!ed || +ed[2] !== cell.c || +ed[3] !== cell.r) ws.setValueFromCoords(cell.c, cell.r, cell.display, true); |
| paint.repaint(cell.r, cell.c); |
| }); |
| } finally { |