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 RichTextArea namespace handling

Alexander Brandon Colesb966007f4cdc
diff --git a/lib/primer/open_project/forms/rich_text_area.rb b/lib/primer/open_project/forms/rich_text_area.rb
index a40d6dcd033..123a50d9e20 100644
--- a/lib/primer/open_project/forms/rich_text_area.rb
+++ b/lib/primer/open_project/forms/rich_text_area.rb
@@ -15,7 +15,12 @@ module Primer
@rich_text_data = rich_text_options.delete(:data) { {} }
@rich_text_data[:"test-selector"] ||= "augmented-text-area-#{@input.name}"
@rich_text_options = rich_text_options
- @text_area_id = @input.id || builder.field_id(@input.name)
+ @text_area_id =
+ if @input.id
+ [builder.options[:namespace], @input.id].compact.join("_")
+ else
+ builder.field_id(@input.name)
+ end
end
end
end
diff --git a/spec/lib/primer/open_project/forms/rich_text_area_spec.rb b/spec/lib/primer/open_project/forms/rich_text_area_spec.rb
index 95042379a95..f4b0c6b8ae9 100644
--- a/spec/lib/primer/open_project/forms/rich_text_area_spec.rb
+++ b/spec/lib/primer/open_project/forms/rich_text_area_spec.rb
@@ -90,20 +90,7 @@ RSpec.describe Primer::OpenProject::Forms::RichTextArea, type: :forms do
context "with explicit field id" do
let(:params) { { id: "explicit_id", rich_text_options: {} } }
- it "renders the label" do
- expect(rendered_form).to have_element :label, for: "explicit_id"
- end
-
- it "renders the hidden textarea" do
- pending "Primer Forms does not handle ids consistently when a form namespace is set."
-
- expect(rendered_form).to have_field "explicit_id", type: "textarea", visible: :hidden
- end
-
- it "renders the rich text area" do
- expect(rendered_form).to have_element "opce-ckeditor-augmented-textarea",
- "data-text-area-id": "explicit_id".to_json
- end
+ it_behaves_like "successful render", text_area_id: "super_form_explicit_id"
end
end
end