Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark combobox as queried when selecting on small screens #192

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Combobox.Filtering = Base => class extends Base {
}

_markQueried() {
this._actingCombobox.toggleAttribute("data-queried", this._isQueried)
this._forAllComboboxes(el => el.toggleAttribute("data-queried", this._isQueried))
}

get _isQueried() {
Expand Down
22 changes: 22 additions & 0 deletions test/system/hotwire_combobox_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,28 @@ class HotwireComboboxTest < ApplicationSystemTestCase
assert_combobox_display_and_value "#state-field", "Alabama", "AL"
end

test "selecting an option marks combobox as queried" do
visit async_path

assert_no_selector ".hw-combobox__input[data-queried]"
open_combobox "#movie-field"
click_on_option "Aladdin"
assert_closed_combobox
assert_combobox_display_and_value "#movie-field", "Aladdin", movies(:aladdin).id
assert_selector ".hw-combobox__input[data-queried]"

on_small_screen do
visit async_path

assert_no_selector ".hw-combobox__input[data-queried]"
open_combobox "#movie-field"
click_on_option "Aladdin"
assert_closed_combobox
assert_combobox_display_and_value "#movie-field", "Aladdin", movies(:aladdin).id
assert_selector ".hw-combobox__input[data-queried]"
end
end

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

Expand Down