From aeafeea6e68ea053cb7a5e9cb4eb353e4bd3502a Mon Sep 17 00:00:00 2001 From: Adam Rutkowski Date: Tue, 5 Sep 2023 10:44:46 +0200 Subject: [PATCH] Add hint to creatable ComboBoxes without suggestions available --- lib/plausible_web/live/components/combo_box.ex | 6 ++++++ test/plausible_web/live/components/combo_box_test.exs | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/plausible_web/live/components/combo_box.ex b/lib/plausible_web/live/components/combo_box.ex index 7b98a7522..e223d8a1b 100644 --- a/lib/plausible_web/live/components/combo_box.ex +++ b/lib/plausible_web/live/components/combo_box.ex @@ -195,6 +195,12 @@ defmodule PlausibleWeb.Live.Components.ComboBox do > No matches found. Try searching for something different. +
+ Create an item by typing. +
""" end diff --git a/test/plausible_web/live/components/combo_box_test.exs b/test/plausible_web/live/components/combo_box_test.exs index 1220ee50f..7280b91b1 100644 --- a/test/plausible_web/live/components/combo_box_test.exs +++ b/test/plausible_web/live/components/combo_box_test.exs @@ -123,6 +123,15 @@ defmodule PlausibleWeb.Live.Components.ComboBoxTest do "No matches found. Try searching for something different." end + test "when no options available, hints the user to create one by typing" do + doc = + render_sample_component([], + creatable: true + ) + + assert text_of_element(doc, "#dropdown-test-component div") == "Create an item by typing." + end + test "makes the html input required when required option is passed" do input_query = "input[type=text][required]" assert render_sample_component([], required: true) |> element_exists?(input_query)