From 7cbf59df2d211d3f3e5c0de4eeec1680c6907ea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Thu, 17 Mar 2022 13:29:47 +0100 Subject: [PATCH] MOBILE-3814 rte: Do not hide toolbar when clicked inside element --- .../core-editor-rich-text-editor.html | 2 +- .../rich-text-editor/rich-text-editor.ts | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/core/features/editor/components/rich-text-editor/core-editor-rich-text-editor.html b/src/core/features/editor/components/rich-text-editor/core-editor-rich-text-editor.html index 5e1ad41d8..a89f6356f 100644 --- a/src/core/features/editor/components/rich-text-editor/core-editor-rich-text-editor.html +++ b/src/core/features/editor/components/rich-text-editor/core-editor-rich-text-editor.html @@ -110,7 +110,7 @@ - diff --git a/src/core/features/editor/components/rich-text-editor/rich-text-editor.ts b/src/core/features/editor/components/rich-text-editor/rich-text-editor.ts index d9b8c4abf..c152c6c41 100644 --- a/src/core/features/editor/components/rich-text-editor/rich-text-editor.ts +++ b/src/core/features/editor/components/rich-text-editor/rich-text-editor.ts @@ -177,8 +177,6 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterContentIn this.editorElement.oninput = this.onChange.bind(this); this.editorElement.onkeydown = this.moveCursor.bind(this); - await CoreDomUtils.waitToBeVisible(this.editorElement); - // Use paragraph on enter. document.execCommand('DefaultParagraphSeparator', false, 'p'); @@ -340,7 +338,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterContentIn return; } - if (this.isNullOrWhiteSpace(this.editorElement.innerText)) { + if (this.isNullOrWhiteSpace(this.editorElement.textContent)) { this.clearText(); } else { // The textarea and the form control must receive the original URLs. @@ -719,8 +717,17 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterContentIn /** * Hide the toolbar in phone mode. + * + * @param event Event. + * @param force If true it will not check the target of the event. */ - hideToolbar(event: Event): void { + hideToolbar(event: Event, force = false): void { + if (!force && event.target && this.element.contains(event.target as HTMLElement)) { + // Do not hide if clicked inside the editor area, except forced. + + return; + } + if (event.type == 'keyup' && !this.isValidKeyboardKey(event)) { return; }