Skip to content

Commit

Permalink
[FIX] Top_bar: Opening a menu should close the composer
Browse files Browse the repository at this point in the history
The composer would not close its assistant when it lost focus, which was
confusing, specifically when opening a topbar menu for instance.
A proper fix f behaviour would require some refactoring of the edition
plugin so in stable, we propose to close the composer when opening a
topbar menu.

closes #2250

Task: 3076218
X-original-commit: 711c4ed
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
  • Loading branch information
aath-odoo committed Mar 21, 2023
1 parent 45f4c5c commit e42786a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/top_bar/top_bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ export class TopBar extends Component<Props, SpreadsheetChildEnv> {
this.state.menuState.parentMenu = menu;
this.isSelectingMenu = true;
this.openedEl = ev.target as HTMLElement;
this.env.model.dispatch("STOP_EDITION");
}

closeMenus() {
Expand Down
9 changes: 9 additions & 0 deletions tests/components/spreadsheet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ describe("Simple Spreadsheet Component", () => {
const sheets = document.querySelectorAll(".o-all-sheets .o-sheet");
expect(sheets).toHaveLength(model.getters.getSheetIds().length - 1);
});

test("The composer helper should be closed on toggle topbar context menu", async () => {
await typeInComposerGrid("=sum(");
expect(parent.model.getters.getEditionMode()).not.toBe("inactive");
expect(fixture.querySelectorAll(".o-composer-assistant")).toHaveLength(1);
await simulateClick(".o-topbar-topleft .o-topbar-menu");
expect(parent.model.getters.getEditionMode()).toBe("inactive");
expect(fixture.querySelectorAll(".o-composer-assistant")).toHaveLength(0);
});
});

test("Can instantiate a spreadsheet with a given client id-name", async () => {
Expand Down
10 changes: 10 additions & 0 deletions tests/components/top_bar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -871,3 +871,13 @@ describe("Topbar - menu item resizing with viewport", () => {
);
});
});

test("The composer helper should be closed on toggle topbar context menu", async () => {
const { model, fixture } = await mountSpreadsheet();
await typeInComposerTopBar("=sum(");
expect(model.getters.getEditionMode()).not.toBe("inactive");
expect(fixture.querySelectorAll(".o-composer-assistant")).toHaveLength(1);
await simulateClick(".o-topbar-topleft .o-topbar-menu");
expect(model.getters.getEditionMode()).toBe("inactive");
expect(fixture.querySelectorAll(".o-composer-assistant")).toHaveLength(0);
});

0 comments on commit e42786a

Please sign in to comment.