MOBILE-4470 rte: Fix rte auto focused on enter
parent
ba72120574
commit
211231a0a8
Binary file not shown.
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 24 KiB |
|
@ -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.
|
||||
*
|
||||
* <ion-input [core-auto-focus]="showKeyboard">
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -299,9 +299,6 @@ export class CoreDomUtilsProvider {
|
|||
async focusElement(
|
||||
element: HTMLIonInputElement | HTMLIonTextareaElement | HTMLIonSearchbarElement | HTMLIonButtonElement | HTMLElement,
|
||||
): Promise<void> {
|
||||
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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue