MOBILE-4470 rte: Fix RTE outside ion-item

main
Pau Ferrer Ocaña 2024-05-10 11:00:09 +02:00
parent f4697a298a
commit 19473b345f
1 changed files with 12 additions and 6 deletions

View File

@ -218,11 +218,7 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit,
this.deleteDraftOnSubmitOrCancel(); this.deleteDraftOnSubmitOrCancel();
} }
const ionItem = this.element.closest<HTMLIonItemElement>('ion-item'); this.setupIonItem();
if (!ionItem) {
return;
}
ionItem.classList.add('item-rte');
if (this.editorElement) { if (this.editorElement) {
const debounceMutation = CoreUtils.debounce(() => { const debounceMutation = CoreUtils.debounce(() => {
@ -232,9 +228,19 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit,
this.contentObserver = new MutationObserver(debounceMutation); this.contentObserver = new MutationObserver(debounceMutation);
this.contentObserver.observe(this.editorElement, { childList: true, subtree: true, characterData: true }); this.contentObserver.observe(this.editorElement, { childList: true, subtree: true, characterData: true });
} }
}
/**
* Setup Ion Item adding classes and managing aria-labelledby.
*/
protected setupIonItem(): void {
const ionItem = this.element.closest<HTMLIonItemElement>('ion-item');
if (!ionItem) {
return;
}
ionItem.classList.add('item-rte');
const label = ionItem.querySelector('ion-label'); const label = ionItem.querySelector('ion-label');
if (!label) { if (!label) {
return; return;
} }