Skip to content

Commit

Permalink
Add tests for quick_tags and fix failing tags tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ringvold committed Dec 12, 2024
1 parent 3db95ff commit 4717fbf
Show file tree
Hide file tree
Showing 3 changed files with 537 additions and 5 deletions.
6 changes: 2 additions & 4 deletions lib/live_select/component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,13 @@ defmodule LiveSelect.Component do
extra_params
)
when active_option >= 0 do
option = Enum.at(socket.assigns.options, active_option)
option = Enum.at(options, active_option)

if already_selected?(option, selection) do
pos = get_selection_index(option, selection)
unselect(socket, pos)
else
select(socket, Enum.at(socket.assigns.options, socket.assigns.active_option), extra_params)
select(socket, Enum.at(options, active_option), extra_params)
end
end

Expand Down Expand Up @@ -710,7 +710,6 @@ defmodule LiveSelect.Component do
defp next_selectable(%{
options: options,
active_option: active_option,
selection: selection,
mode: :quick_tags
}) do
options
Expand Down Expand Up @@ -739,7 +738,6 @@ defmodule LiveSelect.Component do
defp prev_selectable(%{
options: options,
active_option: active_option,
selection: selection,
mode: :quick_tags
}) do
options
Expand Down
2 changes: 1 addition & 1 deletion lib/live_select/component.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
)
)
}
data-idx={idx}
data-idx={if @mode == :quick_tags or not already_selected?(option, @selection), do: idx}
>
<%= if @option == [] do %>
<%= option.label %>
Expand Down
Loading

0 comments on commit 4717fbf

Please sign in to comment.