From d912d9d9af3398458a7739a2bcbd0173a05ed3b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Wed, 13 Dec 2023 15:31:42 +0100 Subject: [PATCH] MOBILE-3947 behat: Fix RTE behat setField --- .../rich-text-editor/core-editor-rich-text-editor.html | 2 +- .../components/rich-text-editor/rich-text-editor.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 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 8daa430f7..029b97c3d 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 @@ -6,7 +6,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 2d54bd8f6..48787de7f 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 @@ -231,11 +231,18 @@ export class CoreEditorRichTextEditorComponent implements OnInit, AfterViewInit, return; } - const updateArialabelledBy = () => this.ariaLabelledBy = label.getAttribute('id') ?? undefined; + const updateArialabelledBy = () => { + this.ariaLabelledBy = label.getAttribute('id') ?? undefined; + }; this.labelObserver = new MutationObserver(updateArialabelledBy); this.labelObserver.observe(label, { attributes: true, attributeFilter: ['id'] }); + // Usually the label won't have an id, so we need to add one. + if (!label.getAttribute('id')) { + label.setAttribute('id', 'rte-'+CoreUtils.getUniqueId('CoreEditorRichTextEditor')); + } + updateArialabelledBy(); }