Merge pull request #16808 from calixteman/editor_no_newline_freetext
[Editor] Avoid to add a new line when hitting enter with a selected freetext editor
This commit is contained in:
commit
ec2b717705
@ -485,6 +485,8 @@ class FreeTextEditor extends AnnotationEditor {
|
|||||||
keydown(event) {
|
keydown(event) {
|
||||||
if (event.target === this.div && event.key === "Enter") {
|
if (event.target === this.div && event.key === "Enter") {
|
||||||
this.enterInEditMode();
|
this.enterInEditMode();
|
||||||
|
// Avoid to add an unwanted new line.
|
||||||
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,20 @@ describe("FreeText Editor", () => {
|
|||||||
await waitForSelectedEditor(page, getEditorSelector(0));
|
await waitForSelectedEditor(page, getEditorSelector(0));
|
||||||
await waitForStorageEntries(page, 1);
|
await waitForStorageEntries(page, 1);
|
||||||
|
|
||||||
const content = await page.$eval(getEditorSelector(0), el =>
|
let content = await page.$eval(getEditorSelector(0), el =>
|
||||||
|
el.innerText.trimEnd()
|
||||||
|
);
|
||||||
|
expect(content).withContext(`In ${browserName}`).toEqual(data);
|
||||||
|
|
||||||
|
// Edit again.
|
||||||
|
await page.keyboard.press("Enter");
|
||||||
|
await page.waitForTimeout(10);
|
||||||
|
|
||||||
|
// Commit.
|
||||||
|
await page.keyboard.press("Escape");
|
||||||
|
await page.waitForTimeout(10);
|
||||||
|
|
||||||
|
content = await page.$eval(getEditorSelector(0), el =>
|
||||||
el.innerText.trimEnd()
|
el.innerText.trimEnd()
|
||||||
);
|
);
|
||||||
expect(content).withContext(`In ${browserName}`).toEqual(data);
|
expect(content).withContext(`In ${browserName}`).toEqual(data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user