feat(core): close the floating sidebar when creating and opening a doc (#8535)

close AF-1478

https://github.com/user-attachments/assets/5a2a27f3-7df3-4119-9a1a-1372353e4413
This commit is contained in:
JimmFly 2024-10-17 14:02:09 +00:00
parent bfb8d582ed
commit 2f2e03d3f9
No known key found for this signature in database
GPG Key ID: 126E0320FEB0D05C

View File

@ -1,4 +1,5 @@
import { toast } from '@affine/component';
import { AppSidebarService } from '@affine/core/modules/app-sidebar';
import { EditorSettingService } from '@affine/core/modules/editor-settting';
import { WorkbenchService } from '@affine/core/modules/workbench';
import type { DocMode } from '@blocksuite/affine/blocks';
@ -7,16 +8,24 @@ import { type DocProps, DocsService, useServices } from '@toeverything/infra';
import { useCallback, useMemo } from 'react';
export const usePageHelper = (docCollection: DocCollection) => {
const { docsService, workbenchService, editorSettingService } = useServices({
const {
docsService,
workbenchService,
editorSettingService,
appSidebarService,
} = useServices({
DocsService,
WorkbenchService,
EditorSettingService,
AppSidebarService,
});
const workbench = workbenchService.workbench;
const docRecordList = docsService.list;
const appSidebar = appSidebarService.sidebar;
const createPageAndOpen = useCallback(
(mode?: DocMode, open?: boolean | 'new-tab') => {
appSidebar.setHovering(false);
const docProps: DocProps = {
note: editorSettingService.editorSetting.get('affine:note'),
};
@ -31,7 +40,13 @@ export const usePageHelper = (docCollection: DocCollection) => {
});
return page;
},
[docRecordList, docsService, editorSettingService, workbench]
[
appSidebar,
docRecordList,
docsService,
editorSettingService.editorSetting,
workbench,
]
);
const createEdgelessAndOpen = useCallback(