@@ -8,31 +8,30 @@ const onAddPanel = panel => {
88 observePanelActiveChange ( panel )
99}
1010const observePanelActiveChange = panel => {
11- panel . api . onDidActiveChange ( ( { isActive } ) => {
12- if ( isActive && ! panel . group . api . isMaximized ( ) ) {
11+ panel . api . onDidVisibilityChange ( ( { isVisible } ) => {
12+ const dockview = panel . accessor ;
13+ if ( dockview . _isDisposed ) return ;
14+ const renderer = dockview . params . options . renderer ;
15+ if ( renderer === 'onlyWhenVisible' && dockview . _inited && isVisible ) {
1316 saveConfig ( panel . accessor )
14- if ( panel . group . panels . length >= 2 ) {
15- panel . group . panels . filter ( p => p != panel . group . activePanel && p . renderer == 'onlyWhenVisible' ) . forEach ( p => {
17+ if ( ! panel . group . api . isMaximized ( ) ) {
18+ panel . group . panels . filter ( p => p != panel . group . activePanel ) . forEach ( p => {
1619 appendTemplatePanelEle ( p )
1720 } )
1821 }
22+ const visiblePanels = dockview . groups . map ( g => g . panels . find ( p => p . params . isActive ) || g . panels . find ( p => p . api . isVisible ) )
23+ dockview . _loadTabs ?. fire ( visiblePanels . filter ( p => Boolean ( p ) ) . map ( p => p . params . key ) ) ;
1924 }
20- if ( isActive && panel . group . getParams ( ) . floatType == 'drawer' ) {
25+
26+ if ( isVisible && panel . group . getParams ( ) . floatType == 'drawer' ) {
2127 setDrawerTitle ( panel . group )
2228 }
23- setTimeout ( function ( ) {
29+ const handler = setTimeout ( function ( ) {
30+ clearTimeout ( handler )
31+ if ( dockview . _isDisposed ) return ;
2432 moveAlwaysRenderPanel ( panel )
2533 } , 0 )
2634 } )
27- panel . api . onDidVisibilityChange ( ( { isVisible } ) => {
28- const dockview = panel . accessor ;
29- if ( dockview . params . options . renderer === 'onlyWhenVisible' && dockview . _inited && isVisible ) {
30- setTimeout ( function ( ) {
31- const visiblePanels = dockview . groups . map ( g => g . panels . find ( p => p . params . isActive ) || g . panels . find ( p => p . api . isVisible ) )
32- dockview . _loadTabs ?. fire ( visiblePanels . filter ( p => Boolean ( p ) ) . map ( p => p . params . key ) ) ;
33- } , 0 )
34- }
35- } )
3635}
3736
3837const moveAlwaysRenderPanel = panel => {
@@ -176,7 +175,7 @@ const savePanel = (dockview, panel) => {
176175
177176const deletePanel = ( dockview , panel ) => {
178177 const { panels, options } = dockview . params ;
179- let index = panels . indexOf ( panel ) ;
178+ let index = panels . findIndex ( p => p . params . key === panel . params . key ) ;
180179 if ( index > - 1 ) {
181180 panels . splice ( index , 1 ) ;
182181 }
0 commit comments