Skip to content

Commit 411165c

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 #7552 Task: 5354541 X-original-commit: 0da6c8d Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
1 parent e81dd16 commit 411165c

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
@@ -154,7 +154,7 @@ export abstract class AbstractComposerStore extends SpreadsheetStore {
154154
}
155155
this.selectionStart = start;
156156
this.selectionEnd = end;
157-
this.editionMode = "editing";
157+
this.stopComposerRangeSelection();
158158
this.computeFormulaCursorContext();
159159
this.computeParenthesisRelatedToCursor();
160160
this.updateAutoCompleteProvider();

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
@@ -125,6 +125,12 @@ describe("edition", () => {
125125
expect(composerStore.editionMode).toBe("inactive");
126126
});
127127

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

0 commit comments

Comments
 (0)