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.

fix(core): fix falsy e2e (#6027)

EYHNdce3b59c522e
diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor-container.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor-container.tsx
index d4d9967fdf..2fc251fa3a 100644
--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor-container.tsx
+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/blocksuite-editor-container.tsx
@@ -205,25 +205,27 @@ export const BlocksuiteEditorContainer = forwardRef<
useEffect(() => {
if (blockElement) {
- requestIdleCallback(() => {
- if (mode === 'page') {
- blockElement.scrollIntoView({
- behavior: 'smooth',
- block: 'center',
- inline: 'center',
+ affineEditorContainerProxy.updateComplete
+ .then(() => {
+ if (mode === 'page') {
+ blockElement.scrollIntoView({
+ behavior: 'smooth',
+ block: 'center',
+ inline: 'center',
+ });
+ }
+ const selectManager = affineEditorContainerProxy.host?.selection;
+ if (!blockElement.path.length || !selectManager) {
+ return;
+ }
+ const newSelection = selectManager.create('block', {
+ path: blockElement.path,
});
- }
- const selectManager = affineEditorContainerProxy.host?.selection;
- if (!blockElement.path.length || !selectManager) {
- return;
- }
- const newSelection = selectManager.create('block', {
- path: blockElement.path,
- });
- selectManager.set([newSelection]);
- });
+ selectManager.set([newSelection]);
+ })
+ .catch(console.error);
}
- }, [blockElement, affineEditorContainerProxy.host?.selection, mode]);
+ }, [blockElement, affineEditorContainerProxy, mode]);
return (
<div