Skip to content

Commit

Permalink
always use span for option label
Browse files Browse the repository at this point in the history
  • Loading branch information
woylie committed Feb 12, 2024
1 parent 21129d2 commit 778f14d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
8 changes: 6 additions & 2 deletions lib/doggo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,9 @@ defmodule Doggo do
assigns = assign(assigns, label: label, value: value, option: nil)

~H"""
<li role="option" data-value={@value}><%= @label %></li>
<li role="option" data-value={@value}>
<span class="combobox-option-label"><%= @label %></span>
</li>
"""
end

Expand All @@ -1278,7 +1280,9 @@ defmodule Doggo do

defp combobox_option(assigns) do
~H"""
<li role="option" data-value={@option}><%= @option %></li>
<li role="option" data-value={@option}>
<span class="combobox-option-label"><%= @option %></span>
</li>
"""
end

Expand Down
16 changes: 12 additions & 4 deletions test/doggo_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1773,12 +1773,16 @@ defmodule DoggoTest do
assert li = find_one(ul, "li:first-child")
assert attribute(li, "role") == "option"
assert attribute(li, "data-value") == "Blue"
assert text(li) == "Blue"
span = find_one(li, "span:first-child")
assert attribute(span, "class") == "combobox-option-label"
assert text(span) == "Blue"

assert li = find_one(ul, "li:last-child")
assert attribute(li, "role") == "option"
assert attribute(li, "data-value") == "Green"
assert text(li) == "Green"
span = find_one(li, "span:last-child")
assert attribute(span, "class") == "combobox-option-label"
assert text(span) == "Green"

input = find_one(div, "input[type='hidden']")
assert attribute(input, "id") == "color-selector-value"
Expand Down Expand Up @@ -1830,11 +1834,15 @@ defmodule DoggoTest do

li = find_one(ul, "li:first-child")
assert attribute(li, "data-value") == "blue"
assert text(li) == "Blue"
span = find_one(li, "span:first-child")
assert attribute(span, "class") == "combobox-option-label"
assert text(span) == "Blue"

li = find_one(ul, "li:last-child")
assert attribute(li, "data-value") == "green"
assert text(li) == "Green"
span = find_one(li, "span:last-child")
assert attribute(span, "class") == "combobox-option-label"
assert text(span) == "Green"
end

test "with option labels and descriptions" do
Expand Down

0 comments on commit 778f14d

Please sign in to comment.