Skip to content
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
1 change: 1 addition & 0 deletions lib/live_select/component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ defmodule LiveSelect.Component do
else
[selected]
end
|> Enum.reject(&is_nil/1)

socket =
socket
Expand Down
19 changes: 19 additions & 0 deletions test/live_select_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@
assert_option_active(
live,
1,
get_in(expected_class(), [@style || default_style(), :active_option]) || ""

Check warning on line 868 in test/live_select_test.exs

View workflow job for this annotation

GitHub Actions / build (1.15, 26)

this check/guard will always yield the same result

Check warning on line 868 in test/live_select_test.exs

View workflow job for this annotation

GitHub Actions / build (1.14.1, 25)

this check/guard will always yield the same result
)
end

Expand Down Expand Up @@ -899,7 +899,7 @@
assert_selected_option_class(
live,
2,
get_in(expected_class(), [@style || default_style(), :selected_option]) || []

Check warning on line 902 in test/live_select_test.exs

View workflow job for this annotation

GitHub Actions / build (1.15, 26)

this check/guard will always yield the same result

Check warning on line 902 in test/live_select_test.exs

View workflow job for this annotation

GitHub Actions / build (1.14.1, 25)

this check/guard will always yield the same result
)
end

Expand Down Expand Up @@ -935,7 +935,7 @@
assert_available_option_class(
live,
2,
get_in(expected_class(), [@style || default_style(), :available_option]) || []

Check warning on line 938 in test/live_select_test.exs

View workflow job for this annotation

GitHub Actions / build (1.15, 26)

this check/guard will always yield the same result

Check warning on line 938 in test/live_select_test.exs

View workflow job for this annotation

GitHub Actions / build (1.14.1, 25)

this check/guard will always yield the same result
)
end

Expand Down Expand Up @@ -971,7 +971,7 @@
assert_unavailable_option_class(
live,
2,
get_in(expected_class(), [@style || default_style(), :unavailable_option]) || []

Check warning on line 974 in test/live_select_test.exs

View workflow job for this annotation

GitHub Actions / build (1.15, 26)

this check/guard will always yield the same result

Check warning on line 974 in test/live_select_test.exs

View workflow job for this annotation

GitHub Actions / build (1.14.1, 25)

this check/guard will always yield the same result
)
end

Expand Down Expand Up @@ -1106,4 +1106,23 @@
assert_selected(live, "A")
end
end

test "handles nil in options list when navigating and clearing input", %{conn: conn} do
stub_options([{"A", 1}, {"B", 2}, {"C", 3}])

{:ok, live, _html} = live(conn, "/")

type(live, "ABC")

assert_options(live, ["A", "B", "C"])

keydown(live, "ArrowDown")
keydown(live, "Backspace")

type(live, "")

keydown(live, "Enter")

refute_selected(live)
end
end
Loading