Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix ARIA label generation for CKEditor

Alexander Brandon Coles6bf31400ed07
diff --git a/frontend/src/app/shared/components/editor/components/ckeditor-augmented-textarea/ckeditor-augmented-textarea.component.ts b/frontend/src/app/shared/components/editor/components/ckeditor-augmented-textarea/ckeditor-augmented-textarea.component.ts
index 0d0fc718a38..0eed7c63d8a 100644
--- a/frontend/src/app/shared/components/editor/components/ckeditor-augmented-textarea/ckeditor-augmented-textarea.component.ts
+++ b/frontend/src/app/shared/components/editor/components/ckeditor-augmented-textarea/ckeditor-augmented-textarea.component.ts
@@ -58,6 +58,7 @@ import { fromEvent } from 'rxjs';
import { AttachmentCollectionResource } from 'core-app/features/hal/resources/attachment-collection-resource';
import { populateInputsFromDataset } from 'core-app/shared/components/dataset-inputs';
import { navigator } from '@hotwired/turbo';
+import { uniqueId } from 'lodash';
@Component({
@@ -286,12 +287,20 @@ export class CkeditorAugmentedTextareaComponent extends UntilDestroyedMixin impl
private setLabel() {
const textareaId = this.textareaSelector.substring(1);
- const label = jQuery(`label[for=${textareaId}]`);
+ const label = document.querySelector<HTMLLabelElement>(`label[for=${textareaId}]`)!;
- const ckContent = this.element.querySelector('.ck-content') as HTMLElement;
+ const ckContent = this.element.querySelector<HTMLElement>('.ck-content')!;
+
+ let labelId;
+ if (label.hasAttribute('id')) {
+ labelId = label.getAttribute('id')!;
+ } else {
+ labelId = uniqueId('label-');
+ label.setAttribute('id', labelId);
+ }
ckContent.removeAttribute('aria-label');
- ckContent.setAttribute('aria-labelledby', textareaId);
+ ckContent.setAttribute('aria-labelledby', labelId);
fromEvent(label, 'click')
.pipe(this.untilDestroyed())