mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-03-01 09:24:05 +08:00
Fix tab content disappearning in nested tabs
This commit is contained in:
parent
0b5da01bd4
commit
c9f619a84a
1 changed files with 6 additions and 3 deletions
|
@ -39,15 +39,18 @@ defmodule LivebookWeb.Output.TabsComponent do
|
|||
~H"""
|
||||
<div id={@id}>
|
||||
<div class="tabs mb-2" id={"#{@id}-tabs"}>
|
||||
<%!-- Note that we use > in the phx-click selectors, because there may be nested tabs --%>
|
||||
<button
|
||||
:for={{output_idx, label} <- @labels}
|
||||
id={"#{@id}-tabs-#{output_idx}"}
|
||||
class={["tab", output_idx == @active_idx && "active"]}
|
||||
phx-click={
|
||||
JS.remove_class("active", to: "##{@id}-tabs .tab.active")
|
||||
JS.remove_class("active", to: "##{@id}-tabs > .tab.active")
|
||||
|> JS.add_class("active")
|
||||
|> JS.add_class("hidden", to: "##{@id} [data-tab-content]:not(.hidden)")
|
||||
|> JS.remove_class("hidden", to: ~s/##{@id} [data-tab-content="#{output_idx}"]/)
|
||||
|> JS.add_class("hidden", to: "##{@id}-tab-contents > [data-tab-content]:not(.hidden)")
|
||||
|> JS.remove_class("hidden",
|
||||
to: ~s/##{@id}-tab-contents > [data-tab-content="#{output_idx}"]/
|
||||
)
|
||||
}
|
||||
>
|
||||
{label}
|
||||
|
|
Loading…
Reference in a new issue