feat(core): hide sidebar when sidebar is not visible (#11560)
This commit is contained in:
@@ -45,6 +45,7 @@ import {
|
|||||||
} from 'react';
|
} from 'react';
|
||||||
|
|
||||||
import { ViewService } from '../services/view';
|
import { ViewService } from '../services/view';
|
||||||
|
import { WorkbenchService } from '../services/workbench';
|
||||||
|
|
||||||
interface ViewIslandRegistry {
|
interface ViewIslandRegistry {
|
||||||
[key: string]: Island | undefined;
|
[key: string]: Island | undefined;
|
||||||
@@ -167,7 +168,12 @@ export const ViewSidebarTab = ({
|
|||||||
unmountOnInactive?: boolean;
|
unmountOnInactive?: boolean;
|
||||||
}>) => {
|
}>) => {
|
||||||
const view = useService(ViewService).view;
|
const view = useService(ViewService).view;
|
||||||
|
const workbench = useService(WorkbenchService).workbench;
|
||||||
|
const sidebarOpened = useLiveData(workbench.sidebarOpen$);
|
||||||
const activeTab = useLiveData(view.activeSidebarTab$);
|
const activeTab = useLiveData(view.activeSidebarTab$);
|
||||||
|
|
||||||
|
const isActive = activeTab?.id === tabId && sidebarOpened;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
view.addSidebarTab(tabId);
|
view.addSidebarTab(tabId);
|
||||||
return () => {
|
return () => {
|
||||||
@@ -179,7 +185,7 @@ export const ViewSidebarTab = ({
|
|||||||
<>
|
<>
|
||||||
<ViewIsland id={`${view.id}:sidebar:${tabId}:icon`}>{icon}</ViewIsland>
|
<ViewIsland id={`${view.id}:sidebar:${tabId}:icon`}>{icon}</ViewIsland>
|
||||||
<ViewIsland id={`${view.id}:sidebar:${tabId}:body`}>
|
<ViewIsland id={`${view.id}:sidebar:${tabId}:body`}>
|
||||||
{unmountOnInactive && activeTab?.id !== tabId ? null : children}
|
{unmountOnInactive && !isActive ? null : children}
|
||||||
</ViewIsland>
|
</ViewIsland>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user