Skip to content

Commit

Permalink
Don't apply customizations to non-customized attrs (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
josefarias committed May 31, 2024
1 parent eae73f0 commit f457b49
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/presenters/hotwire_combobox/component/customizable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions test/helpers/hotwire_combobox/helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f457b49

Please sign in to comment.