Skip to content

Commit

Permalink
Fix dismissing chips
Browse files Browse the repository at this point in the history
  • Loading branch information
josefarias committed May 4, 2024
1 parent acf5403 commit ea037fd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/assets/javascripts/hw_combobox/models/combobox/toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Combobox.Toggle = Base => class extends Base {
this._isSync &&
!this._isSmallViewport &&
inputType != "hw:clickOutside" &&
inputType != "hw:focusOutside"
inputType != "hw:focusOutside" &&
inputType != "hw:asyncCloser"

this._lockInSelection()
this._clearInvalidQuery()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
label: "States",
multiselect_chip_src: dismissing_state_chips_path,
placeholder: "Select states" %>

<%= combobox_tag "async_state", states_path,
id: "async-states-field",
label: "Async States",
multiselect_chip_src: dismissing_state_chips_path,
placeholder: "Select states" %>
19 changes: 19 additions & 0 deletions test/system/hotwire_combobox_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ class HotwireComboboxTest < ApplicationSystemTestCase
open_combobox "#user_visited_state_ids"
type_in_combobox "#user_visited_state_ids", "Lou"
click_on_option "Louisiana"
assert_open_combobox
assert_text "Alabama" # combobox is reset and still open

assert_combobox_display_and_value \
Expand Down Expand Up @@ -966,6 +967,24 @@ class HotwireComboboxTest < ApplicationSystemTestCase
states(:illinois, :louisiana).pluck(:id)
end

test "multiselect with dismissing streams" do
visit multiselect_dismissing_path

assert_closed_combobox

open_combobox "#states-field"
type_in_combobox "#states-field", "Lou"
click_on_option "Louisiana"
sleep 1
assert_closed_combobox

open_combobox "#async-states-field"
type_in_combobox "#async-states-field", "Lou"
click_on_option "Louisiana"
sleep 1
assert_closed_combobox
end

test "multiselect custom events" do
visit multiselect_custom_events_path

Expand Down

0 comments on commit ea037fd

Please sign in to comment.