@@ -61,13 +62,17 @@ defmodule PlausibleWeb.Live.FunnelSettings.InputPicker do
end
def open_dropdown(js \\ %JS{}, id) do
- JS.show(js, to: "#dropdown-#{id}")
+ js |> close_all_dropdowns() |> JS.show(to: "#dropdown-#{id}")
end
def close_dropdown(js \\ %JS{}, id) do
JS.hide(js, to: "#dropdown-#{id}")
end
+ def close_all_dropdowns(js \\ %JS{}) do
+ JS.hide(js, to: ".dropdown")
+ end
+
attr :ref, :string, required: true
attr :options, :list, default: []
attr :choices, :list, default: []
@@ -79,7 +84,7 @@ defmodule PlausibleWeb.Live.FunnelSettings.InputPicker do
+ class="dropdown hidden z-50 absolute mt-1 max-h-60 overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm dark:bg-gray-900">
<.option :if={@choices != []} :for={{{submit_value, display_value}, idx} <- Enum.with_index(@choices)} idx={idx} submit_value={submit_value} display_value={display_value} target={@target} ref={@ref} candidate={@candidate} />
No matches found. Try searching for something different.
@@ -97,16 +102,12 @@ defmodule PlausibleWeb.Live.FunnelSettings.InputPicker do
def option(assigns) do
~H"""
-
-
- <%= @display_value %>
-
+
+
+
+ <%= @display_value %>
+
+
"""
end