How to add and remove a Widget from the main area layout without creating and disposing of the Widget?

I am trying to figure out how to toggle the presence of a Widget in the “main area” without having to create and destroy it each time. In the implementation here,

etc-jupyterlab-telemetry/console_log.ts at bf92a2ddf46b0b7cf558949e71c521c43fe52f7c · educational-technology-collective/etc-jupyterlab-telemetry · GitHub

, I am using DocLayout#.addWidget and DocLayout#removeWidget in order to toggle its visibility. However, when I do this it does something that breaks the main area, as, for example, I cannot load the Advanced Settings Panel after I have toggled it on and off. As such, although it seems to work, I am sure I am doing something wrong.

Does anyone know what I am doing wrong, or can anyone direct me to a working example?

Thank you.

1 Like