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

Apply unique IDs for each help text dialog

Alexander Brandon Coles6f4000bb92dc
diff --git a/app/components/attribute_help_texts/show_dialog_component.rb b/app/components/attribute_help_texts/show_dialog_component.rb
index 93ac44f425f..c8759159639 100644
--- a/app/components/attribute_help_texts/show_dialog_component.rb
+++ b/app/components/attribute_help_texts/show_dialog_component.rb
@@ -31,8 +31,6 @@
class AttributeHelpTexts::ShowDialogComponent < ApplicationComponent
include OpTurbo::Streamable
- DIALOG_ID = "attribute-help-text-show-modal"
-
def initialize(attribute_help_text:, current_user: User.current)
super
@attribute_help_text = attribute_help_text
@@ -41,7 +39,7 @@ class AttributeHelpTexts::ShowDialogComponent < ApplicationComponent
private
- def dialog_id = DIALOG_ID
+ def dialog_id = dom_id(@attribute_help_text, :dialog)
def title = @attribute_help_text.attribute_caption
diff --git a/spec/components/attribute_help_texts/show_dialog_component_spec.rb b/spec/components/attribute_help_texts/show_dialog_component_spec.rb
index fe62f4dc726..757acfac76d 100644
--- a/spec/components/attribute_help_texts/show_dialog_component_spec.rb
+++ b/spec/components/attribute_help_texts/show_dialog_component_spec.rb
@@ -50,6 +50,14 @@ RSpec.describe AttributeHelpTexts::ShowDialogComponent, type: :component do
page
end
+ it "renders a dialog" do
+ expect(subject).to have_element :dialog
+ end
+
+ it "applies an ID" do
+ expect(subject).to have_element id: "dialog_attribute_help_text_project_#{attribute_help_text.id}"
+ end
+
describe "dialog heading" do
it "renders the heading" do
expect(subject).to have_heading attribute_help_text.attribute_caption