Skip to content

Commit d90a9b4

Browse files
authored
Bug: fix duplicated ids in toggle_switch component (#446)
1 parent bc41c15 commit d90a9b4

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

lib/live_debugger_web/components.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ defmodule LiveDebuggerWeb.Components do
590590
attr(:checked, :boolean, default: false, doc: "Whether the switch is checked.")
591591
attr(:label, :string, default: "", doc: "Label for the switch.")
592592
attr(:wrapper_class, :any, default: nil, doc: "Additional classes to add to the switch.")
593+
attr(:id, :string, default: nil, doc: "ID of the switch.")
593594
attr(:rest, :global)
594595

595596
def toggle_switch(assigns) do
@@ -601,7 +602,7 @@ defmodule LiveDebuggerWeb.Components do
601602
<span class="text-xs font-normal text-primary-text mx-2">
602603
<%= @label %>
603604
</span>
604-
<input id="highlight-switch" type="checkbox" class="sr-only peer" checked={@checked} {@rest} />
605+
<input id={@id} type="checkbox" class="sr-only peer" checked={@checked} {@rest} />
605606
<div class="relative w-9 h-5 bg-ui-muted peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-ui-accent rounded-full peer peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-ui-surface after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-ui-accent ">
606607
</div>
607608
</label>

lib/live_debugger_web/components/tree.ex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ defmodule LiveDebuggerWeb.Components.Tree do
3636
<div class="flex items-center justify-between">
3737
<div class="shrink-0 font-medium text-secondary-text px-6 py-3"><%= @title %></div>
3838
<%= if LiveDebugger.Feature.enabled?(:highlighting) do %>
39-
<.toggle_switch label="Highlight" checked={@highlight?} phx-click="toggle-highlight" />
39+
<.toggle_switch
40+
id="highlight-switch"
41+
label="Highlight"
42+
checked={@highlight?}
43+
phx-click="toggle-highlight"
44+
/>
4045
<% end %>
4146
</div>
4247
<div class="flex-1">

0 commit comments

Comments
 (0)