Skip to content

Commit 0da6c8d

Browse files
committed
[FIX] composer: keep edition mode inactive on cursor selection change
Before this commit: - Changing the composer cursor selection triggered a switch to edition mode, even when the composer was inactive. - This caused unwanted activation of editing while simply moving the selection. After this commit: - Selection changes no longer modify the edition mode when the composer is inactive, ensuring the edition state remains stable. closes #7548 Task: 5354541 X-original-commit: 790c2c5 Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
1 parent cb92d82 commit 0da6c8d

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/components/composer/composer/abstract_composer_store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export abstract class AbstractComposerStore extends SpreadsheetStore {
131131
}
132132
this.selectionStart = start;
133133
this.selectionEnd = end;
134-
this.editionMode = "editing";
134+
this.stopComposerRangeSelection();
135135
this.computeFormulaCursorContext();
136136
this.computeParenthesisRelatedToCursor();
137137
}

tests/composer/composer_integration_component.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
getElComputedStyle,
3434
gridMouseEvent,
3535
keyDown,
36+
keyUp,
3637
rightClickCell,
3738
selectColumnByClicking,
3839
simulateClick,
@@ -361,6 +362,15 @@ describe("Composer interactions", () => {
361362
expect(composerStore.editionMode).toBe("inactive");
362363
});
363364

365+
test("should switch topbar composer from editing to inactive when pressing Escape on cell A1 containing '=A2'", async () => {
366+
setCellContent(model, "A1", "=A2");
367+
await click(fixture, ".o-spreadsheet-topbar .o-composer");
368+
expect(composerStore.editionMode).toBe("editing");
369+
keyDown({ key: "Escape" });
370+
keyUp({ key: "Escape" });
371+
expect(composerStore.editionMode).toBe("inactive");
372+
});
373+
364374
test("ArrowKeys will move to neighbour cell, if not in contentFocus mode (left/right)", async () => {
365375
let composerEl: Element;
366376
composerEl = await startComposition("a");

tests/composer/composer_store.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ describe("edition", () => {
124124
expect(composerStore.editionMode).toBe("inactive");
125125
});
126126

127+
test("should keep edition mode inactive when selection changes while composer is inactive", () => {
128+
expect(composerStore.editionMode).toBe("inactive");
129+
composerStore.changeComposerCursorSelection(0, 0);
130+
expect(composerStore.editionMode).toBe("inactive");
131+
});
132+
127133
test("should switch to editing mode when composer cursor selection changes", () => {
128134
composerStore.startEdition("=sum(");
129135
expect(composerStore.editionMode).toBe("selecting");

0 commit comments

Comments
 (0)