diff --git a/app/components/editable_champ/drop_down_list_component.rb b/app/components/editable_champ/drop_down_list_component.rb index 0f92a95bc..04f901550 100644 --- a/app/components/editable_champ/drop_down_list_component.rb +++ b/app/components/editable_champ/drop_down_list_component.rb @@ -23,4 +23,13 @@ class EditableChamp::DropDownListComponent < EditableChamp::EditableChampBaseCom max_length = 100 @champ.enabled_non_empty_options.any? { _1.size > max_length } end + + def react_props + react_input_opts(id: @champ.input_id, + class: 'fr-mt-1w', + name: @form.field_name(:value), + selected_key: @champ.selected, + items: @champ.enabled_non_empty_options(other: true).map { _1.is_a?(Array) ? _1 : [_1, _1] }, + empty_filter_key: @champ.drop_down_other? ? Champs::DropDownListChamp::OTHER : nil) + end end diff --git a/app/components/editable_champ/drop_down_list_component/drop_down_list_component.html.haml b/app/components/editable_champ/drop_down_list_component/drop_down_list_component.html.haml index c2268eba0..3ce73c3ee 100644 --- a/app/components/editable_champ/drop_down_list_component/drop_down_list_component.html.haml +++ b/app/components/editable_champ/drop_down_list_component/drop_down_list_component.html.haml @@ -18,7 +18,8 @@ %label.fr-label{ for: dom_id(@champ, "radio_option_other") } = t('shared.champs.drop_down_list.other') - elsif @champ.render_as_combobox? - = render Dsfr::ComboboxComponent.new form: @form, options: @champ.enabled_non_empty_options(other: true), selected: @champ.selected, input_html_options: { name: :value, id: @champ.input_id, class: select_class_names, describedby: @champ.describedby_id } + %react-fragment + = render ReactComponent.new "ComboBox/SingleComboBox", **react_props - else = @form.select :value, @champ.enabled_non_empty_options(other: true), diff --git a/app/models/champ.rb b/app/models/champ.rb index 093829236..c144fb470 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -285,7 +285,7 @@ class Champ < ApplicationRecord return if value.nil? return if value.present? && !value.include?("\u0000") - self.value = value.delete("\u0000") + write_attribute(:value, value.delete("\u0000")) end class NotImplemented < ::StandardError