Skip to content

Commit

Permalink
[FIX] Composer: pressing enter in the link editor
Browse files Browse the repository at this point in the history
Previously, pressing Enter in the link editor would inadvertently open
the grid composer in edit mode, which was not the expected behavior.
This commit addresses the issue by adding a check in the onInput method
of the composer component.

closes #4033

Taskid: 3796114
X-original-commit: cbd04c9
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
  • Loading branch information
dhrp-odoo committed Apr 10, 2024
1 parent 246caf7 commit 3c4d398
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/link/link_editor/link_editor.ts
Expand Up @@ -176,6 +176,7 @@ export class LinkEditor extends Component<LinkEditorProps, SpreadsheetChildEnv>
this.save();
}
ev.stopPropagation();
ev.preventDefault();
break;
case "Escape":
this.cancel();
Expand Down
15 changes: 15 additions & 0 deletions tests/composer/composer_component.test.ts
Expand Up @@ -33,6 +33,7 @@ import {
import {
ComposerWrapper,
mountComposerWrapper,
mountSpreadsheet,
nextTick,
typeInComposerHelper,
} from "../test_helpers/helpers";
Expand Down Expand Up @@ -517,6 +518,20 @@ describe("composer", () => {
expect(link?.url).toBe("http://odoo.com");
});

test("Pressing Enter while editing a label does not open grid composer", async () => {
({ model, fixture } = await mountSpreadsheet());
setCellContent(model, "A1", "[label](http://odoo.com)");
await simulateClick(".o-topbar-menu[data-id='insert']");
await simulateClick(".o-menu-item[data-name='insert_link']");
const editor = fixture.querySelector(".o-link-editor");
expect(editor).toBeTruthy();

editor!.querySelectorAll("input")[0].focus();
await keyDown({ key: "Enter" });
expect(fixture.querySelector(".o-link-editor")).toBeFalsy();
expect(model.getters.getEditionMode()).toBe("inactive");
});

describe("change selecting mode when typing specific token value", () => {
const matchingValues = [",", "+", "*", "="];
const mismatchingValues = ["1", '"coucou"', "TRUE", "SUM", "A2"];
Expand Down

0 comments on commit 3c4d398

Please sign in to comment.