diff --git a/src/addons/mod/forum/tests/behat/snapshots/test-basic-usage-of-forum-activity-in-app-reply-a-post_14.png b/src/addons/mod/forum/tests/behat/snapshots/test-basic-usage-of-forum-activity-in-app-reply-a-post_14.png index cfab8bca1..0aabac3e0 100644 Binary files a/src/addons/mod/forum/tests/behat/snapshots/test-basic-usage-of-forum-activity-in-app-reply-a-post_14.png and b/src/addons/mod/forum/tests/behat/snapshots/test-basic-usage-of-forum-activity-in-app-reply-a-post_14.png differ diff --git a/src/core/directives/auto-focus.ts b/src/core/directives/auto-focus.ts index 48071cd1b..eb550ac35 100644 --- a/src/core/directives/auto-focus.ts +++ b/src/core/directives/auto-focus.ts @@ -22,7 +22,7 @@ import { CoreDom } from '@singletons/dom'; * Directive to auto focus an element when a view is loaded. * * The value of the input will decide if show keyboard when focusing the element (only on Android). - * In case value is nofocus, the directive is disabled. + * In case value is false, the directive is disabled. * * */ 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 e2ed8eb1b..e39a3a882 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 @@ -435,6 +435,10 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit, * @param parent Parent where to set the position. */ protected setCurrentCursorPosition(parent: Node): void { + if (!this.rteEnabled || !this.element.classList.contains('has-focus')) { + return; + } + const range = document.createRange(); // Select all so it will go to the end. @@ -600,7 +604,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit, this.control?.setValue(null, { emitEvent: false }); setTimeout(() => { - if (this.rteEnabled && this.editorElement) { + if (this.editorElement) { this.setCurrentCursorPosition(this.editorElement); } }, 1); diff --git a/src/core/services/utils/dom.ts b/src/core/services/utils/dom.ts index cb97417eb..e73338425 100644 --- a/src/core/services/utils/dom.ts +++ b/src/core/services/utils/dom.ts @@ -299,9 +299,6 @@ export class CoreDomUtilsProvider { async focusElement( element: HTMLIonInputElement | HTMLIonTextareaElement | HTMLIonSearchbarElement | HTMLIonButtonElement | HTMLElement, ): Promise { - let retries = 10; - - const isIonButton = element.tagName === 'ION-BUTTON'; let elementToFocus = element; /** @@ -318,6 +315,7 @@ export class CoreDomUtilsProvider { } } + const isIonButton = element.tagName === 'ION-BUTTON'; if ('getInputElement' in elementToFocus) { // If it's an Ionic element get the right input to use. elementToFocus.componentOnReady && await elementToFocus.componentOnReady(); @@ -332,6 +330,7 @@ export class CoreDomUtilsProvider { throw new CoreError('Element to focus cannot be focused'); } + let retries = 10; while (retries > 0 && elementToFocus !== document.activeElement) { elementToFocus.focus();