diff --git a/app/components/dsfr/input_status_message_component.rb b/app/components/dsfr/input_status_message_component.rb index 78a88a0da..d8aaca740 100644 --- a/app/components/dsfr/input_status_message_component.rb +++ b/app/components/dsfr/input_status_message_component.rb @@ -2,10 +2,10 @@ module Dsfr class InputStatusMessageComponent < ApplicationComponent - def initialize(errors_on_attribute:, error_full_messages:, describedby_id:, champ:) + def initialize(errors_on_attribute:, error_full_messages:, champ:) @errors_on_attribute = errors_on_attribute @error_full_messages = error_full_messages - @describedby_id = describedby_id + @error_id = champ.error_id @champ = champ end end diff --git a/app/components/dsfr/input_status_message_component/input_status_message_component.html.haml b/app/components/dsfr/input_status_message_component/input_status_message_component.html.haml index 9edef67b1..cb08bac2a 100644 --- a/app/components/dsfr/input_status_message_component/input_status_message_component.html.haml +++ b/app/components/dsfr/input_status_message_component/input_status_message_component.html.haml @@ -1,4 +1,4 @@ -.fr-messages-group{ id: @describedby_id } +.fr-messages-group{ id: @error_id, aria: { live: :assertive } } - if @error_full_messages.size > 0 %p{ class: class_names('fr-message' => true, "fr-message--#{@errors_on_attribute ? 'error' : 'valid'}" => true) } = "« #{@champ.libelle} » " diff --git a/app/components/editable_champ/champ_label_component/champ_label_component.html.haml b/app/components/editable_champ/champ_label_component/champ_label_component.html.haml index e76a0da5b..99f662e46 100644 --- a/app/components/editable_champ/champ_label_component/champ_label_component.html.haml +++ b/app/components/editable_champ/champ_label_component/champ_label_component.html.haml @@ -4,7 +4,7 @@ = @form.label @champ.main_value_name, id: @champ.labelledby_id, for: @champ.input_id, class: 'fr-label' do - render EditableChamp::ChampLabelContentComponent.new form: @form, champ: @champ, seen_at: @seen_at - if @champ.description.present? - .fr-hint-text= render SimpleFormatComponent.new(@champ.description, allow_a: true) + .fr-hint-text{ id: @champ.describedby_id }= render SimpleFormatComponent.new(@champ.description, allow_a: true) - elsif @champ.legend_label? %legend.fr-fieldset__legend.fr-text--regular.fr-pb-1w{ id: @champ.labelledby_id }= render EditableChamp::ChampLabelContentComponent.new form: @form, champ: @champ, seen_at: @seen_at - if @champ.description.present? diff --git a/app/components/editable_champ/editable_champ_component/editable_champ_component.html.haml b/app/components/editable_champ/editable_champ_component/editable_champ_component.html.haml index 06ff21348..462af6735 100644 --- a/app/components/editable_champ/editable_champ_component/editable_champ_component.html.haml +++ b/app/components/editable_champ/editable_champ_component/editable_champ_component.html.haml @@ -5,4 +5,4 @@ = render champ_component - = render Dsfr::InputStatusMessageComponent.new(errors_on_attribute: champ_component.errors_on_attribute?, error_full_messages: champ_component.error_full_messages, describedby_id: @champ.describedby_id, champ: @champ) + = render Dsfr::InputStatusMessageComponent.new(errors_on_attribute: champ_component.errors_on_attribute?, error_full_messages: champ_component.error_full_messages, champ: @champ) diff --git a/app/components/editable_champ/text_component/text_component.html.haml b/app/components/editable_champ/text_component/text_component.html.haml index e88fc3332..b300ed2d4 100644 --- a/app/components/editable_champ/text_component/text_component.html.haml +++ b/app/components/editable_champ/text_component/text_component.html.haml @@ -1 +1 @@ -= @form.text_field(:value, input_opts(id: @champ.input_id, required: @champ.required?, aria: { describedby: @champ.describedby_id })) += @form.text_field(:value, input_opts(id: @champ.input_id, required: @champ.required?, aria: { describedby:"#{@champ.describedby_id} #{@champ.error_id}" })) diff --git a/app/models/champ.rb b/app/models/champ.rb index 1062221dc..474d04ecc 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -179,6 +179,10 @@ class Champ < ApplicationRecord "#{html_id}-describedby_id" end + def error_id + "#{html_id}-error_id" + end + def log_fetch_external_data_exception(exception) update_column(:fetch_external_data_exceptions, [exception.inspect]) end