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

Use `visually_hide_label` option instead

Kabiru Mwenja86eb9eaceff6
diff --git a/app/forms/work_packages/activities_tab/journals/notes_form.rb b/app/forms/work_packages/activities_tab/journals/notes_form.rb
index 06a1e709ed1..59d9a315683 100644
--- a/app/forms/work_packages/activities_tab/journals/notes_form.rb
+++ b/app/forms/work_packages/activities_tab/journals/notes_form.rb
@@ -33,12 +33,12 @@ module WorkPackages::ActivitiesTab::Journals
notes_form.rich_text_area(
classes: "ck-editor-primer-adjusted",
name: :notes,
- label: nil,
+ label: I18n.t("activities.work_packages.activity_tab.label_type_to_comment"),
+ visually_hide_label: true,
rich_text_options: {
showAttachments: false,
resource:,
- editor_type: "constrained",
- aria_label: I18n.t("activities.work_packages.activity_tab.label_type_to_comment")
+ editor_type: "constrained"
}
)
end
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 abf25e8a1c4..0637b17e177 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
@@ -67,8 +67,6 @@ import { uniqueId } from 'lodash';
export class CkeditorAugmentedTextareaComponent extends UntilDestroyedMixin implements OnInit {
@Input() public textAreaId:string;
- @Input() public textAreaAriaLabel:string;
-
@Input() public previewContext:string;
@Input() public macros:ICKEditorMacroType;
@@ -221,12 +219,10 @@ export class CkeditorAugmentedTextareaComponent extends UntilDestroyedMixin impl
// Set initial label
this.setLabel();
- // Use focusTracker to maintain aria-label as CKEditor re-renders ARIA-label every time on focus/blur
+ // Use focusTracker to maintain aria-labelledby as CKEditor re-renders aria-label on every focus/blur event
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
- editor.ui.focusTracker.on('change:isFocused', (_evt:unknown, _name:string, isFocused:boolean) => {
- if (isFocused) {
- this.setLabel();
- }
+ editor.ui.focusTracker.on('change:isFocused', (_evt:unknown, _name:string, _isFocused:boolean) => {
+ this.setLabel();
});
return editor;
@@ -321,10 +317,8 @@ export class CkeditorAugmentedTextareaComponent extends UntilDestroyedMixin impl
.pipe(this.untilDestroyed())
.subscribe(() => ckContent.focus());
}
- } else if (this.textAreaAriaLabel) {
- ckContent.setAttribute('aria-label', this.textAreaAriaLabel);
} else {
- throw new Error(`Please provide a label for the textarea with id ${this.textAreaId} or set the textAreaAriaLabel property.`);
+ console.error(`Please provide a label for the textarea with id ${this.textAreaId}`);
}
}
}
diff --git a/lib/primer/open_project/forms/rich_text_area.html.erb b/lib/primer/open_project/forms/rich_text_area.html.erb
index 461db3f7fbd..0379d716982 100644
--- a/lib/primer/open_project/forms/rich_text_area.html.erb
+++ b/lib/primer/open_project/forms/rich_text_area.html.erb
@@ -5,7 +5,7 @@
**@input.input_arguments) %>
<% end %>
<%= angular_component_tag "opce-ckeditor-augmented-textarea",
- inputs: rich_text_options.reverse_merge(
+ inputs: @rich_text_options.reverse_merge(
{
textAreaId: @text_area_id,
macros: false,
diff --git a/lib/primer/open_project/forms/rich_text_area.rb b/lib/primer/open_project/forms/rich_text_area.rb
index 94064ed8f8a..c0276720a62 100644
--- a/lib/primer/open_project/forms/rich_text_area.rb
+++ b/lib/primer/open_project/forms/rich_text_area.rb
@@ -17,14 +17,6 @@ module Primer
@rich_text_options = rich_text_options
@text_area_id = rich_text_options.delete(:text_area_id) || builder.field_id(@input.name)
end
-
- private
-
- def rich_text_options
- @rich_text_options.tap do |options|
- options[:textAreaAriaLabel] = options.delete(:aria_label) if options.key?(:aria_label)
- end
- end
end
end
end
diff --git a/spec/features/activities/work_package/activity_tab_comment_editor_spec.rb b/spec/features/activities/work_package/activity_tab_comment_editor_spec.rb
index 3fb78b1611c..493712e0482 100644
--- a/spec/features/activities/work_package/activity_tab_comment_editor_spec.rb
+++ b/spec/features/activities/work_package/activity_tab_comment_editor_spec.rb
@@ -126,14 +126,23 @@ RSpec.describe "Work package activity tab comment editor",
wp_page.wait_for_activity_tab
end
- it "has an aria-label on the editor" do
+ it "has the rich text editor aria labelled" do
activity_tab.add_comment(text: "Sample text", save: false)
activity_tab.expect_focus_on_editor
+ expect_rich_text_to_be_aria_labelled
- within_test_selector("augmented-text-area-notes") do
- expect(page).to have_css(".ck-content[aria-label='Add a comment. Type @ to notify people.']")
- end
+ activity_tab.clear_comment(blur: true)
+
+ activity_tab.expect_blur_on_editor
+ expect_rich_text_to_be_aria_labelled
+ end
+
+ def expect_rich_text_to_be_aria_labelled
+ expect(page).to have_selector(:label, for: "journal_notes", class: "sr-only",
+ text: "Add a comment. Type @ to notify people.")
+ label_id = page.find('label[for="journal_notes"]')["id"]
+ expect(page).to have_selector(:rich_text, aria: { labelledby: label_id })
end
end
diff --git a/spec/support/components/work_packages/activities.rb b/spec/support/components/work_packages/activities.rb
index 03f3e4759ff..fb8e8470ee8 100644
--- a/spec/support/components/work_packages/activities.rb
+++ b/spec/support/components/work_packages/activities.rb
@@ -216,6 +216,12 @@ module Components
end
end
+ def expect_blur_on_editor
+ page.within_test_selector("op-work-package-journal-form-element") do
+ expect(page).to have_css(".ck-content:not(:focus)", wait: 10)
+ end
+ end
+
def expect_activity_anchor_link(text:)
expect(page).to have_test_selector("activity-anchor-link", text:)
end