@@ -10,8 +10,9 @@ defmodule LiveDebugger.App.Debugger.Web.Components.NavigationMenu do
1010 alias Phoenix.LiveView.JS
1111
1212 attr ( :class , :any , default: nil , doc: "Additional classes to add to the navigation bar." )
13- attr ( :current_url , :any , required: true )
14- attr ( :return_link , :any , required: true , doc: "Link to navigate to." )
13+ attr ( :current_url , :string , required: true )
14+ attr ( :return_link , :string , required: true , doc: "Link to navigate to." )
15+ attr ( :dropdown_id , :string , required: true )
1516
1617 slot ( :inspect_button )
1718
@@ -46,7 +47,12 @@ defmodule LiveDebugger.App.Debugger.Web.Components.NavigationMenu do
4647 />
4748 </ div >
4849
49- < . dropdown return_link = { @ return_link } current_url = { @ current_url } class = "sm:hidden " />
50+ < . dropdown
51+ return_link = { @ return_link }
52+ current_url = { @ current_url }
53+ class = "sm:hidden "
54+ id = { @ dropdown_id }
55+ />
5056
5157 < div id = "hidden-items " class = "hidden sm:flex flex-row gap-3 " >
5258 < . navbar_item
@@ -64,6 +70,7 @@ defmodule LiveDebugger.App.Debugger.Web.Components.NavigationMenu do
6470 attr ( :class , :any , default: nil , doc: "Additional classes to add to the navigation bar." )
6571 attr ( :return_link , :any , required: true , doc: "Link to navigate to." )
6672 attr ( :current_url , :any , required: true )
73+ attr ( :id , :string , required: true )
6774
6875 def dropdown ( assigns ) do
6976 assigns =
@@ -75,7 +82,7 @@ defmodule LiveDebugger.App.Debugger.Web.Components.NavigationMenu do
7582 ~H"""
7683 < . live_component
7784 module = { LiveDropdown }
78- id = " navigation-bar-dropdown "
85+ id = { " #{ @ id } - navigation-bar-dropdown"}
7986 class = { @ class }
8087 direction = { :bottom_left }
8188 >
@@ -96,7 +103,7 @@ defmodule LiveDebugger.App.Debugger.Web.Components.NavigationMenu do
96103 icon = "icon-chart-line "
97104 label = "Resources "
98105 selected? = { @ current_view == "resources" }
99- phx-click = { dropdown_item_click ( RoutesHelper . debugger_resources ( @ pid ) ) }
106+ phx-click = { dropdown_item_click ( RoutesHelper . debugger_resources ( @ pid ) , @ id ) }
100107 />
101108 </ div >
102109 </ . live_component >
@@ -124,10 +131,10 @@ defmodule LiveDebugger.App.Debugger.Web.Components.NavigationMenu do
124131 end
125132
126133 # We do it to make sure that the dropdown is closed when the item is clicked.
127- defp dropdown_item_click ( url ) do
134+ defp dropdown_item_click ( url , id ) do
128135 url
129136 |> JS . patch ( )
130- |> JS . push ( "close" , target: "#navigation-bar-dropdown-live-dropdown-container" )
137+ |> JS . push ( "close" , target: "##{ id } - navigation-bar-dropdown-live-dropdown-container" )
131138 end
132139
133140 attr ( :id , :string , required: true )
0 commit comments