From 8cdee167f8d5a00d51d424db364e05a43242fdfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 12 Jul 2021 01:15:40 +0200 Subject: [PATCH] Fix duplicate HTML ID in document fields Using `dom_id` means generating `new_document` as ID for new documents. Since there might be more than one new document in the form, that means duplicate IDs, which is invalid HTML. Even though this issue doesn't affect image fields (because we don't have many images on the same form), we're removing the ID there as well for consistency. --- app/components/documents/fields_component.html.erb | 2 +- app/components/images/fields_component.html.erb | 2 +- spec/shared/system/nested_documentable.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/components/documents/fields_component.html.erb b/app/components/documents/fields_component.html.erb index 4dc0c42ff..91d1a19d5 100644 --- a/app/components/documents/fields_component.html.erb +++ b/app/components/documents/fields_component.html.erb @@ -1,4 +1,4 @@ -
+
<%= f.hidden_field :id %> <%= f.hidden_field :user_id, value: current_user.id %> <%= f.hidden_field :cached_attachment %> diff --git a/app/components/images/fields_component.html.erb b/app/components/images/fields_component.html.erb index bff9555f1..00985abc0 100644 --- a/app/components/images/fields_component.html.erb +++ b/app/components/images/fields_component.html.erb @@ -1,4 +1,4 @@ -
+
<%= f.hidden_field :id %> <%= f.hidden_field :user_id, value: current_user.id %> <%= f.hidden_field :cached_attachment %> diff --git a/spec/shared/system/nested_documentable.rb b/spec/shared/system/nested_documentable.rb index b6b1175a6..ed2eabbef 100644 --- a/spec/shared/system/nested_documentable.rb +++ b/spec/shared/system/nested_documentable.rb @@ -320,7 +320,7 @@ end def documentable_attach_new_file(path, success = true) click_link "Add new document" - document = all("#new_document").last + document = all(".document").last document_input = document.find("input[type=file]", visible: :hidden) attach_file(document_input[:id], path, make_visible: true)