diff --git a/app/components/attachment/edit_component.rb b/app/components/attachment/edit_component.rb index 15069dc48..6450a94be 100644 --- a/app/components/attachment/edit_component.rb +++ b/app/components/attachment/edit_component.rb @@ -132,9 +132,8 @@ class Attachment::EditComponent < ApplicationComponent def input_id if champ.present? - # Single or first attachment input must match label "for" attribute. Others must remain unique. - return champ.input_id if @index.zero? - return "#{champ.input_id}_#{attachment_id}" + # There is always a single input by champ, its id must match the label "for" attribute. + return champ.input_id end helpers.field_id(@attached_file.record, attribute_name) diff --git a/app/components/attachment/edit_component/edit_component.html.haml b/app/components/attachment/edit_component/edit_component.html.haml index 5b810d57a..16671296b 100644 --- a/app/components/attachment/edit_component/edit_component.html.haml +++ b/app/components/attachment/edit_component/edit_component.html.haml @@ -1,4 +1,4 @@ -.attachment.fr-upload-group{ id: attachment ? dom_id(attachment, :edit) : nil, class: class_names("fr-mb-2w": !(as_multiple? && downloadable?)) } +.attachment.fr-upload-group{ { id: attachment ? dom_id(attachment, :edit) : nil, class: class_names("fr-mb-2w": !(as_multiple? && downloadable?)) }.compact } - if persisted? %div{ id: dom_id(attachment, :persisted_row) } .flex.flex-gap-2{ class: class_names("attachment-error": attachment.virus_scanner_error?) }