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 #2237

Task: 3076218
X-original-commit: 07aa9f7
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
  • Loading branch information
aath-odoo authored and rrahir committed Mar 22, 2023
1 parent 066593c commit b68c248
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 @@ -410,6 +410,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 @@ -404,6 +404,15 @@ describe("Composer interactions", () => {
fixture.remove();
app.destroy();
});

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);
});
});

describe("Composer / selectionInput interactions", () => {
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 @@ -864,3 +864,13 @@ describe("Topbar - menu item resizing with viewport", () => {
app.destroy();
});
});

test("The composer helper should be closed on toggle topbar context menu", async () => {
const { parent } = await mountSpreadsheet(fixture);
await typeInComposerTopBar("=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);
});

0 comments on commit b68c248

Please sign in to comment.