diff --git a/app/presenters/hotwire_combobox/component/customizable.rb b/app/presenters/hotwire_combobox/component/customizable.rb index 0fb3e1a..51078dc 100644 --- a/app/presenters/hotwire_combobox/component/customizable.rb +++ b/app/presenters/hotwire_combobox/component/customizable.rb @@ -46,7 +46,7 @@ def apply_customizations_to(element, base: {}) custom = custom_attrs[element] coalesce = ->(key, value) do - if value.is_a?(String) || value.is_a?(Array) + if custom.has_key?(key) && (value.is_a?(String) || value.is_a?(Array)) view.token_list(value, custom.delete(key)) else value diff --git a/test/helpers/hotwire_combobox/helper_test.rb b/test/helpers/hotwire_combobox/helper_test.rb index 3f2d4c4..a7aa165 100644 --- a/test/helpers/hotwire_combobox/helper_test.rb +++ b/test/helpers/hotwire_combobox/helper_test.rb @@ -158,4 +158,12 @@ class HotwireCombobox::HelperTest < ApplicationViewTestCase assert_attrs html, tag_name: "turbo-frame", src: "/foo?bar=baz&qux=quux&page=2&format=turbo_stream" end + + test "single repeating character values" do + form = form_with model: OpenStruct.new(run_at: "* * * * *", persisted?: true, model_name: OpenStruct.new(param_key: :foo)), url: "#" do |form| + form.combobox :run_at, [ "@hourly", "@daily", "@weekly", "@monthly", "@every 4h", "0 12 * * *" ], free_text: true + end + + assert_equal "* * * * *", Nokogiri::HTML(form).css("input[name='foo[run_at]']").first.attr("value") + end end