Skip to content

Commit 0794333

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

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
@@ -149,7 +149,7 @@ export abstract class AbstractComposerStore extends SpreadsheetStore {
149149
}
150150
this.selectionStart = start;
151151
this.selectionEnd = end;
152-
this.editionMode = "editing";
152+
this.stopComposerRangeSelection();
153153
this.computeFormulaCursorContext();
154154
this.computeParenthesisRelatedToCursor();
155155
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
@@ -126,6 +126,12 @@ describe("edition", () => {
126126
expect(composerStore.editionMode).toBe("inactive");
127127
});
128128

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

0 commit comments

Comments
 (0)