handle aria_describedby on react combobox
This commit is contained in:
parent
2e050e2f18
commit
8a0d70ee70
3 changed files with 18 additions and 12 deletions
|
@ -79,12 +79,19 @@ module Dsfr
|
|||
'fr-input': !react,
|
||||
'fr-mb-0': true
|
||||
}.merge(input_error_class_names)))
|
||||
if errors_on_attribute?
|
||||
@opts.deep_merge!('aria-describedby': describedby_id)
|
||||
|
||||
aria_describedby = []
|
||||
|
||||
if object.respond_to?(:description) && object.description.present?
|
||||
aria_describedby << describedby_id
|
||||
elsif hintable?
|
||||
@opts.deep_merge!('aria-describedby': hint_id)
|
||||
aria_describedby << hint_id
|
||||
end
|
||||
|
||||
aria_describedby << object.error_id if errors_on_attribute? && object.respond_to?(:error_id)
|
||||
|
||||
@opts.deep_merge!('aria-describedby': aria_describedby.join(' ')) if aria_describedby.present?
|
||||
|
||||
if @required
|
||||
@opts[react ? :is_required : :required] = true
|
||||
end
|
||||
|
|
|
@ -27,13 +27,13 @@ class EditableChamp::DropDownListComponent < EditableChamp::EditableChampBaseCom
|
|||
end
|
||||
|
||||
def react_props
|
||||
react_input_opts(id: @champ.input_id,
|
||||
react_input_opts(
|
||||
id: @champ.input_id,
|
||||
class: 'fr-mt-1w',
|
||||
name: @form.field_name(:value),
|
||||
selected_key: @champ.selected,
|
||||
items: @champ.drop_down_options_with_other.map { _1.is_a?(Array) ? _1 : [_1, _1] },
|
||||
empty_filter_key: @champ.drop_down_other? ? Champs::DropDownListChamp::OTHER : nil,
|
||||
'aria-describedby': @champ.describedby_id,
|
||||
'aria-labelledby': @champ.labelledby_id)
|
||||
empty_filter_key: @champ.drop_down_other? ? Champs::DropDownListChamp::OTHER : nil
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,14 +12,13 @@ class EditableChamp::MultipleDropDownListComponent < EditableChamp::EditableCham
|
|||
end
|
||||
|
||||
def react_props
|
||||
react_input_opts(id: @champ.input_id,
|
||||
react_input_opts(
|
||||
id: @champ.input_id,
|
||||
class: 'fr-mt-1w',
|
||||
name: @form.field_name(:value, multiple: true),
|
||||
selected_keys: @champ.selected_options,
|
||||
items: @champ.drop_down_options,
|
||||
value_separator: false,
|
||||
'aria-label': @champ.libelle,
|
||||
'aria-describedby': @champ.describedby_id,
|
||||
'aria-labelledby': @champ.labelledby_id)
|
||||
value_separator: false
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue