fix(sheet): Tippen überschreibt den Zellinhalt - #379
Conversation
PR Summary by QodoMake typing overwrite selected spreadsheet cells
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1. AltGr typing still appends
|
| if (!this.activeEdit && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) { | ||
| this.beginOverwrite(td); |
There was a problem hiding this comment.
1. Altgr typing still appends 🐞 Bug ≡ Correctness
The overwrite condition rejects printable keydowns carrying Ctrl or Alt, so layouts and browsers exposing AltGr as Ctrl+Alt skip beginOverwrite() and insert into the existing content. Common international-layout characters therefore append instead of replacing the selected cell.
Agent Prompt
## Issue description
Printable AltGr-generated characters can carry both Ctrl and Alt modifier flags. The current overwrite predicate treats them as shortcuts, so they edit the existing content without first clearing it.
## Issue Context
Distinguish AltGr text input from actual Ctrl/Alt shortcuts, and add coverage for an AltGr-equivalent printable key event.
## Fix Focus Areas
- ui/src/js/sheet/sheetView.ts[362-366]
- playwright/specs/sheet_excel_chrome.spec.ts[162-186]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| td.addEventListener('compositionstart', () => { | ||
| if (!this.activeEdit) this.beginOverwrite(td); |
There was a problem hiding this comment.
2. Canceled composition deletes value 🐞 Bug ≡ Correctness
When an IME composition ends before producing an input value, compositionstart has already emptied the cell. Blurring afterward compares that empty DOM value with the stored value and commits an unintended deletion.
Agent Prompt
## Issue description
The cell is cleared as soon as IME composition starts, before replacement text is guaranteed. A canceled composition that produces no input can consequently commit the cell as empty on blur.
## Issue Context
Arm overwrite mode on `compositionstart`, clear when composition text actually arrives, and restore or preserve the original value when composition is canceled. Add browser coverage for canceling an IME composition before input.
## Fix Focus Areas
- ui/src/js/sheet/sheetView.ts[311-315]
- ui/src/js/sheet/sheetView.ts[377-390]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| td.addEventListener('dblclick', () => { | ||
| this.activeEdit = true; |
There was a problem hiding this comment.
3. Double-click replaces selected word 🐞 Bug ≡ Correctness
Native double-clicking in a contenteditable selects a word, but the new handler only sets activeEdit and never collapses that selection to the clicked caret. The next character can replace the selected word rather than edit at the click position, violating the new preservation test's contract.
Agent Prompt
## Issue description
The double-click handler enables edit mode without overriding the contenteditable's native word selection. Subsequent typing can replace the selected word instead of inserting at the clicked position.
## Issue Context
Prevent or collapse the second-click selection while retaining the caret derived from the click coordinates. Strengthen the browser test to assert the exact resulting value and, if practical, insertion at a non-terminal position.
## Fix Focus Areas
- ui/src/js/sheet/sheetView.ts[306-310]
- playwright/specs/sheet_excel_chrome.spec.ts[180-185]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Ctrl+F / Ctrl+H open an Excel-style dialog with Find Next, Replace and Replace All, plus Match case and Entire cell; the ribbon gets a Find & Select menu in the Editing group. The search runs against the raw cell content, which is Excel default "Look in: Formulas": a formula is found by its text and a replacement rewrites the formula. Find Next walks row-major from the current cell and wraps around. Replace All emits one setCell op per changed cell within a single tick, so the whole sweep is one undo step. Case-insensitive replacement is done by walking the folded string instead of a regex, so untouched parts keep their original casing and no query needs escaping. The view gains setSelection() so a hit can be selected and scrolled into view the same way a click would, notifications included. Not covered: wildcards in the query, searching across all sheets, and Find All as a result list - the dialog reports the match count instead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
704d10a to
5efc964
Compare
Selecting a cell and typing appended to what was already there, because the grid cell is a permanently contenteditable td and the keystroke just went to the caret. Excel overwrites instead, which is what everyone expects from a spreadsheet - and it is what made a two-value edit in the undo e2e test read "firstsecond". The first printable keystroke on a cell that is selected but not being edited now clears it and lets the character land in the empty cell. The escape hatches match Excel: F2 enters edit mode with the caret at the end, double-click edits in place at the click position. IME composition takes the same overwrite path, since it starts without a printable keydown. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
498d3df to
1253b19
Compare
5efc964 to
1b1198c
Compare
Problem
Eine Zelle auswählen und lostippen hat den Text angehängt statt ersetzt. Ursache: die Grid-Zelle ist ein dauerhaft
contenteditabletd, der Tastendruck ging schlicht an den Cursor. Aufgefallen ist es, weil ein Undo-e2e-Test in #377 „firstsecond" statt „second" gelesen hat — der Test war falsch geschrieben, aber das Verhalten dahinter ist der eigentliche Fehler.Excel überschreibt: der erste Tastendruck auf einer ausgewählten Zelle ersetzt den Inhalt.
Fix
Der erste druckbare Tastendruck auf einer Zelle, die ausgewählt aber nicht in Bearbeitung ist, leert sie und lässt das Zeichen in die leere Zelle fallen (kein
preventDefault, der Browser fügt selbst ein). Danach greiftactiveEditund weitere Zeichen hängen normal an.Die Auswege entsprechen Excel:
Test
Playwright: tippen ersetzt, F2 hängt an, Doppelklick bearbeitet an Ort und Stelle. Unit-Tests gibt es dafür keine — es ist reines Browser-Verhalten in der contenteditable-Zelle, und für die View existiert keine DOM-Test-Infrastruktur.
Basis
Dritter Teil der Kette #377 (Undo/Redo) → #378 (Suchen & Ersetzen) → dieser PR. Basis wird nach dem Mergen der Vorgänger auf main gezogen.
🤖 Generated with Claude Code