Skip to content

Commit ef46ea4

Browse files
authored
Merge pull request #237 from opf/feature/danger-dialog-require-title-param
Make title param required for DangerDialog and FeedbackDialog
2 parents 087a3e0 + 694bdae commit ef46ea4

File tree

13 files changed

+80
-27
lines changed

13 files changed

+80
-27
lines changed

.changeset/nasty-oranges-end.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@openproject/primer-view-components': patch
3+
---
4+
5+
Make DangerDialog title param required: Axe will raise accessibility violations in the absence of a title. We want to ensure best a11y practice, so this change makes it a required param and documents it.
6+
7+
This is a BREAKING change.

.changeset/polite-toys-tap.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@openproject/primer-view-components': patch
3+
---
4+
5+
Make FeedbackDialog title param required: Axe will raise accessibility violations in the absence of a title. We want to ensure best a11y practice, so this change makes it a required param and documents it.
6+
7+
This is a BREAKING change.

app/components/primer/open_project/danger_dialog.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ class DangerDialog < Primer::Component
6363

6464
# @param form_arguments [Hash] Allows the dialog to submit a form. Pass EITHER the `builder:` option to this hash to reuse an existing Rails form, or `action:` if you prefer the component to render the form tag itself. `builder:` should be an instance of `ActionView::Helpers::FormBuilder`, which is created by the standard Rails `#form_with` and `#form_for` helpers. The `name:` option is the desired name of the field that will be included in the params sent to the server on form submission.
6565
# @param id [String] The id of the dialog.
66+
# @param title [String] The title of the dialog. Although visually hidden, a label is rendered for assistive technologies.
6667
# @param confirm_button_text [String] The text of the confirm button. Will default to `I18n.t("button_delete")`, or `I18n.t("button_delete_permanently")` if `confirmation_check_box` slot has been passed to the component.
6768
# @param cancel_button_text [String] The text of the cancel button. Will default to `I18n.t("button_cancel")`.
6869
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
6970
def initialize(
7071
form_arguments: {},
7172
id: self.class.generate_id,
73+
title:,
7274
confirm_button_text: nil,
7375
cancel_button_text: nil,
7476
**system_arguments
@@ -87,7 +89,7 @@ def initialize(
8789
"DangerDialog"
8890
)
8991

90-
@dialog = Primer::Alpha::Dialog.new(title: @system_arguments[:title], subtitle: nil, visually_hide_title: true, **@system_arguments)
92+
@dialog = Primer::Alpha::Dialog.new(title: title, subtitle: nil, visually_hide_title: true, **@system_arguments)
9193
end
9294

9395
delegate :labelledby, :header?, :header, :with_header, :with_header_content,

app/components/primer/open_project/feedback_dialog.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,17 @@ class FeedbackDialog < Primer::Component
4040

4141
renders_one :footer
4242

43+
# @param title [String] The title of the dialog. Although visually hidden, a label is rendered for assistive technologies.
4344
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
44-
def initialize(**system_arguments)
45+
def initialize(title:, **system_arguments)
4546
@system_arguments = system_arguments
4647
@system_arguments[:classes] = class_names(
4748
system_arguments[:classes],
4849
"FeedbackDialog"
4950
)
5051
@system_arguments[:id] ||= self.class.generate_id
5152

52-
@dialog = Primer::Alpha::Dialog.new(title: @system_arguments[:title], subtitle: nil, visually_hide_title: true, **@system_arguments)
53+
@dialog = Primer::Alpha::Dialog.new(title: title, subtitle: nil, visually_hide_title: true, **@system_arguments)
5354
end
5455

5556
delegate :header?, :header, :with_header, :with_header_content,

previews/primer/open_project/danger_dialog_preview/with_additional_details.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<%= render(Primer::OpenProject::DangerDialog.new) do |dialog| %>
1+
<%= render(Primer::OpenProject::DangerDialog.new(title: "Delete work packages")) do |dialog| %>
22
<% dialog.with_show_button { "Click me" } %>
33
<% dialog.with_confirmation_message do |message| %>
44
<% message.with_heading(tag: :h2).with_content("Delete 5 work packages?") %>

previews/primer/open_project/feedback_dialog_preview/playground.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<%= render(Primer::OpenProject::FeedbackDialog.new(id: "my-dialog")) do |dialog| %>
1+
<%= render(Primer::OpenProject::FeedbackDialog.new(id: "my-dialog", title: "My dialog")) do |dialog| %>
22
<% dialog.with_show_button { "Click me" } %>
33
<% dialog.with_feedback_message(icon_arguments: { icon: icon, color: icon_color }, loading: loading_state) do |message| %>
44
<% message.with_heading(tag: :h2).with_content("Awesome!") %>

previews/primer/open_project/feedback_dialog_preview/with_additional_details.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<%= render(Primer::OpenProject::FeedbackDialog.new) do |dialog| %>
1+
<%= render(Primer::OpenProject::FeedbackDialog.new(title: "Success message")) do |dialog| %>
22
<% dialog.with_show_button { "Click me" } %>
33
<% dialog.with_feedback_message do |message| %>
44
<% message.with_heading(tag: :h2).with_content("Action successful") %>

previews/primer/open_project/feedback_dialog_preview/with_custom_footer.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<%= render(Primer::OpenProject::FeedbackDialog.new(id: "my-dialog")) do |dialog| %>
1+
<%= render(Primer::OpenProject::FeedbackDialog.new(id: "my-dialog", title: "Custom footer")) do |dialog| %>
22
<% dialog.with_show_button { "Click me" } %>
33
<% dialog.with_feedback_message do |message| %>
44
<% message.with_heading(tag: :h2).with_content("Action successful") %>

static/arguments.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5131,6 +5131,12 @@
51315131
"default": "`self.class.generate_id`",
51325132
"description": "The id of the dialog."
51335133
},
5134+
{
5135+
"name": "title",
5136+
"type": "String",
5137+
"default": "N/A",
5138+
"description": "The title of the dialog. Although visually hidden, a label is rendered for assistive technologies."
5139+
},
51345140
{
51355141
"name": "confirm_button_text",
51365142
"type": "String",
@@ -5214,6 +5220,12 @@
52145220
"source": "https://github.com/primer/view_components/tree/main/app/components/primer/open_project/feedback_dialog.rb",
52155221
"lookbook": "https://primer.style/view-components/lookbook/inspect/primer/open_project/feedback_dialog/default/",
52165222
"parameters": [
5223+
{
5224+
"name": "title",
5225+
"type": "String",
5226+
"default": "N/A",
5227+
"description": "The title of the dialog. Although visually hidden, a label is rendered for assistive technologies."
5228+
},
52175229
{
52185230
"name": "system_arguments",
52195231
"type": "Hash",

static/info_arch.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17532,6 +17532,12 @@
1753217532
"default": "`self.class.generate_id`",
1753317533
"description": "The id of the dialog."
1753417534
},
17535+
{
17536+
"name": "title",
17537+
"type": "String",
17538+
"default": "N/A",
17539+
"description": "The title of the dialog. Although visually hidden, a label is rendered for assistive technologies."
17540+
},
1753517541
{
1753617542
"name": "confirm_button_text",
1753717543
"type": "String",
@@ -17878,6 +17884,12 @@
1787817884
"source": "https://github.com/primer/view_components/tree/main/app/components/primer/open_project/feedback_dialog.rb",
1787917885
"lookbook": "https://primer.style/view-components/lookbook/inspect/primer/open_project/feedback_dialog/default/",
1788017886
"parameters": [
17887+
{
17888+
"name": "title",
17889+
"type": "String",
17890+
"default": "N/A",
17891+
"description": "The title of the dialog. Although visually hidden, a label is rendered for assistive technologies."
17892+
},
1788117893
{
1788217894
"name": "system_arguments",
1788317895
"type": "Hash",

0 commit comments

Comments
 (0)