Merge pull request #8991 from demarches-simplifiees/fix_missing_blank_option_in_mandatory_select

correction: etq usager je veux toujours avoir une liste déroulante sans choix présélectionné
This commit is contained in:
LeSim 2023-09-05 12:30:43 +00:00 committed by GitHub
commit ee0da75952
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 9 deletions

View file

@ -19,7 +19,13 @@
%label.fr-label{ for: "#{@champ.id}_radio_option_other" }
Autre
- else
= @form.select :value, @champ.options_without_empty_value_when_mandatory(@champ.options), { selected: @champ.selected }, required: @champ.required?, id: @champ.input_id, class: select_class_names, aria: { describedby: @champ.describedby_id }
= @form.select :value,
@champ.options.compact_blank,
{ selected: @champ.selected, include_blank: true },
required: @champ.required?,
id: @champ.input_id,
class: select_class_names,
aria: { describedby: @champ.describedby_id }
- if @champ.drop_down_other?
= render EditableChamp::DropDownOtherInputComponent.new(form: @form, champ: @champ)

View file

@ -477,14 +477,6 @@ class TypeDeChamp < ApplicationRecord
end
end
# historicaly we added a blank ("") option by default to avoid wrong selection
# see self.parse_drop_down_list_value
# then rails decided to add this blank ("") option when the select is required
# so we revert this change
def options_without_empty_value_when_mandatory(options)
mandatory? ? options.compact_blank : options
end
def drop_down_list_options?
drop_down_list_options.any?
end