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