Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

feat(core): keep the sidebar instance when the sidebar is collapsed (#8560)

JimmFlya25bb0d80f82
diff --git a/packages/frontend/core/src/modules/app-sidebar/views/index.tsx b/packages/frontend/core/src/modules/app-sidebar/views/index.tsx
index 52e364cc06..28dc9027f8 100644
--- a/packages/frontend/core/src/modules/app-sidebar/views/index.tsx
+++ b/packages/frontend/core/src/modules/app-sidebar/views/index.tsx
@@ -181,6 +181,7 @@ export function AppSidebar({ children }: PropsWithChildren) {
onOpen={handleOpenChange}
onResizing={handleResizing}
onWidthChange={handleWidthChange}
+ unmountOnExit={false}
className={clsx(navWrapperStyle, {
[hoverNavWrapperStyle]: sidebarState === 'floating',
})}
diff --git a/packages/frontend/core/src/modules/app-sidebar/views/sidebar-header/sidebar-switch.tsx b/packages/frontend/core/src/modules/app-sidebar/views/sidebar-header/sidebar-switch.tsx
index 36bca5822e..abc6bfb7dd 100644
--- a/packages/frontend/core/src/modules/app-sidebar/views/sidebar-header/sidebar-switch.tsx
+++ b/packages/frontend/core/src/modules/app-sidebar/views/sidebar-header/sidebar-switch.tsx
@@ -19,9 +19,8 @@ export const SidebarSwitch = ({
const preventHovering = useLiveData(appSidebarService.preventHovering$);
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
const switchRef = useRef<HTMLDivElement>(null);
-
const handleMouseEnter = useCallback(() => {
- if (open || preventHovering) {
+ if (preventHovering || open) {
return;
}
appSidebarService.setHovering(true);
@@ -32,6 +31,7 @@ export const SidebarSwitch = ({
clearTimeout(timeoutRef.current);
}
if (open) {
+ appSidebarService.setHovering(false);
timeoutRef.current = setTimeout(() => {
appSidebarService.setPreventHovering(false);
}, 500);