Skip to content

Commit

Permalink
Show clear widget on prefilled state
Browse files Browse the repository at this point in the history
  • Loading branch information
jlw committed Mar 15, 2024
1 parent cec6a1b commit b1f9745
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Combobox.Selection = Base => class extends Base {
_connectSelection() {
if (this.hasPrefilledDisplayValue) {
this._fullQuery = this.prefilledDisplayValue
this._markQueried()
}
}

Expand Down
11 changes: 10 additions & 1 deletion test/system/hotwire_combobox_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,23 @@ class HotwireComboboxTest < ApplicationSystemTestCase
assert_combobox_display_and_value "#state-field", "Florida", "FL"
end

test "combobox with prefilled value" do
test "combobox with prefilled value and working clear widget" do
visit prefilled_path

assert_closed_combobox
assert_combobox_display_and_value "#state-field", "Michigan", "MI"
assert_selector ".hw-combobox__input[data-queried]"

open_combobox "#state-field"
assert_selected_option_with text: "Michigan"

click_away
find(".hw-combobox__handle").click
assert_open_combobox
assert_no_visible_selected_option

click_away
assert_no_selector ".hw-combobox__input[data-queried]"
end

test "combobox in form with prefilled value" do
Expand Down

0 comments on commit b1f9745

Please sign in to comment.