@@ -339,6 +339,7 @@ export class LayerListPanel extends SidePanel {
339339 sidePanelManager : SidePanelManager ,
340340 public manager : TopLevelLayerListSpecification ,
341341 public state : LayerListPanelState ,
342+ public hideLayerPanel : TrackableBoolean ,
342343 public showLayerPanel ?: TrackableBoolean ,
343344 ) {
344345 super ( sidePanelManager , state . location ) ;
@@ -347,8 +348,9 @@ export class LayerListPanel extends SidePanel {
347348 this . titleElement = titleElement ! ;
348349
349350 // Add layer panel toggle button to title bar
350- if ( this . showLayerPanel ) {
351- const toggleButton = new CheckboxIcon ( this . showLayerPanel , {
351+ // Only show toggle button when showLayerPanel configuration is enabled
352+ if ( this . showLayerPanel ?. value ) {
353+ const toggleButton = new CheckboxIcon ( this . hideLayerPanel , {
352354 svg : svg_eye ,
353355 backgroundScheme : "dark" ,
354356 enableTitle : "Hide layer panel" ,
@@ -357,6 +359,23 @@ export class LayerListPanel extends SidePanel {
357359 toggleButton . element . style . order = "50" ; // Position before close button (order: 100)
358360 titleBar . appendChild ( toggleButton . element ) ;
359361 this . registerDisposer ( toggleButton ) ;
362+
363+ // Watch for showLayerPanel configuration changes and hide/show button accordingly
364+ this . registerDisposer (
365+ this . showLayerPanel . changed . add ( ( ) => {
366+ if ( this . showLayerPanel ! . value ) {
367+ // Configuration enabled - show button
368+ if ( ! toggleButton . element . parentElement ) {
369+ titleBar . appendChild ( toggleButton . element ) ;
370+ }
371+ } else {
372+ // Configuration disabled - hide button
373+ if ( toggleButton . element . parentElement ) {
374+ toggleButton . element . remove ( ) ;
375+ }
376+ }
377+ } ) ,
378+ ) ;
360379 }
361380 itemContainer . classList . add ( "neuroglancer-layer-list-panel-items" ) ;
362381 this . addBody ( itemContainer ) ;
0 commit comments