Skip to content

Commit 790c2c5

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 #7547 Task: 5354541 X-original-commit: 8564f98 Signed-off-by: Rémi Rahir (rar) <[email protected]> Signed-off-by: Ronakkumar Mukeshbhai Bharadiya (rmbh) <[email protected]>
1 parent 91a6b89 commit 790c2c5

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
@@ -110,7 +110,7 @@ export abstract class AbstractComposerStore extends SpreadsheetStore {
110110
}
111111
this.selectionStart = start;
112112
this.selectionEnd = end;
113-
this.editionMode = "editing";
113+
this.stopComposerRangeSelection();
114114
}
115115

116116
stopComposerRangeSelection() {

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,
@@ -365,6 +366,15 @@ describe("Composer interactions", () => {
365366
expect(composerStore.editionMode).toBe("inactive");
366367
});
367368

369+
test("should switch topbar composer from editing to inactive when pressing Escape on cell A1 containing '=A2'", async () => {
370+
setCellContent(model, "A1", "=A2");
371+
await click(fixture, ".o-spreadsheet-topbar .o-composer");
372+
expect(composerStore.editionMode).toBe("editing");
373+
keyDown({ key: "Escape" });
374+
keyUp({ key: "Escape" });
375+
expect(composerStore.editionMode).toBe("inactive");
376+
});
377+
368378
test("ArrowKeys will move to neighbour cell, if not in contentFocus mode (left/right)", async () => {
369379
let composerEl: Element;
370380
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)