Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

ComboBox: revert unused changes (#5061)

hq1421f7610f21b
diff --git a/lib/plausible_web/live/components/combo_box.ex b/lib/plausible_web/live/components/combo_box.ex
index 8d2cde417e..091dfaea20 100644
--- a/lib/plausible_web/live/components/combo_box.ex
+++ b/lib/plausible_web/live/components/combo_box.ex
@@ -68,10 +68,8 @@ defmodule PlausibleWeb.Live.Components.ComboBox do
attr(:suggest_fun, :any, required: true)
attr(:suggestions_limit, :integer)
attr(:class, :string, default: "")
- attr(:clear_on_select, :boolean, default: false)
attr(:required, :boolean, default: false)
attr(:creatable, :boolean, default: false)
- attr(:creatable_prompt, :string, default: "Create")
attr(:errors, :list, default: [])
attr(:async, :boolean, default: Mix.env() != :test)
attr(:on_selection_made, :any)
@@ -138,7 +136,6 @@ defmodule PlausibleWeb.Live.Components.ComboBox do
target={@myself}
creatable={@creatable}
display_value={@display_value}
- creatable_prompt={@creatable_prompt}
/>
</div>
</div>
@@ -173,7 +170,6 @@ defmodule PlausibleWeb.Live.Components.ComboBox do
attr(:suggest_fun, :any, required: true)
attr(:target, :any)
attr(:creatable, :boolean, required: true)
- attr(:creatable_prompt, :string, default: nil)
attr(:display_value, :string, required: true)
def combo_dropdown(assigns) do
@@ -194,7 +190,6 @@ defmodule PlausibleWeb.Live.Components.ComboBox do
target={@target}
ref={@ref}
creatable
- creatable_prompt={@creatable_prompt}
/>
<.option
@@ -235,7 +230,6 @@ defmodule PlausibleWeb.Live.Components.ComboBox do
attr(:target, :any)
attr(:idx, :integer, required: true)
attr(:creatable, :boolean, default: false)
- attr(:creatable_prompt, :string, required: false)
def option(assigns) do
assigns = assign(assigns, :suggestions_limit, suggestions_limit(assigns))
@@ -260,7 +254,7 @@ defmodule PlausibleWeb.Live.Components.ComboBox do
class="block truncate py-2 px-3"
>
<%= if @creatable do %>
- {@creatable_prompt} "{@display_value}"
+ Create "{@display_value}"
<% else %>
{@display_value}
<% end %>
@@ -324,13 +318,6 @@ defmodule PlausibleWeb.Live.Components.ComboBox do
defp do_select(socket, submit_value, display_value) do
id = socket.assigns.id
- display_value =
- if socket.assigns[:clear_on_select] do
- ""
- else
- display_value
- end
-
socket =
socket
|> push_event("update-value", %{id: id, value: display_value, fire: false})
diff --git a/test/plausible_web/live/components/combo_box_test.exs b/test/plausible_web/live/components/combo_box_test.exs
index 5babde7b85..d54872b69b 100644
--- a/test/plausible_web/live/components/combo_box_test.exs
+++ b/test/plausible_web/live/components/combo_box_test.exs
@@ -245,24 +245,6 @@ defmodule PlausibleWeb.Live.Components.ComboBoxTest do
end
end
- defmodule CreatableCustomView do
- use Phoenix.LiveView
-
- def render(assigns) do
- ~H"""
- <.live_component
- submit_name="some_submit_name"
- module={PlausibleWeb.Live.Components.ComboBox}
- suggest_fun={&ComboBox.StaticSearch.suggest/2}
- id="test-creatable-component"
- creatable
- creatable_prompt="Custom Text"
- clear_on_select
- />
- """
- end
- end
-
test "stores selected value from suggestion", %{conn: conn} do
{:ok, lv, _html} = live_isolated(conn, CreatableView, session: %{})
type_into_combo(lv, "test-creatable-component", "option 20")
@@ -330,27 +312,6 @@ defmodule PlausibleWeb.Live.Components.ComboBoxTest do
assert Floki.attribute(creatable_option, "x-on:click") == []
end
-
- test "allows for custom creatable prompt", %{conn: conn} do
- {:ok, lv, _html} = live_isolated(conn, CreatableCustomView, session: %{})
-
- assert lv
- |> type_into_combo("test-creatable-component", "my new option")
- |> text_of_element("li#dropdown-test-creatable-component-option-0 a") ==
- ~s(Custom Text "my new option")
- end
-
- test "clears on select", %{conn: conn} do
- {:ok, lv, _html} = live_isolated(conn, CreatableCustomView, session: %{})
-
- type_into_combo(lv, "test-creatable-component", "my new option")
-
- lv
- |> element("li#dropdown-test-creatable-component-option-0 a")
- |> render_click()
-
- assert lv |> render() |> text_of_attr("#test-creatable-component", "value") == ""
- end
end
describe "async suggestions" do