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(plugin): hide left menu when block change

austaras00f5f239b294
diff --git a/libs/components/editor-plugins/src/menu/group-menu/GropuMenu.tsx b/libs/components/editor-plugins/src/menu/group-menu/GropuMenu.tsx
index 790ee98636..781c2c3a25 100644
--- a/libs/components/editor-plugins/src/menu/group-menu/GropuMenu.tsx
+++ b/libs/components/editor-plugins/src/menu/group-menu/GropuMenu.tsx
@@ -168,6 +168,12 @@ export const GroupMenu = function ({ editor, hooks }: GroupMenuProps) {
useEffect(() => {
setShowMenu(false);
+
+ if (groupBlock) {
+ const unobserve = groupBlock.onUpdate(() => setGroupBlock(null));
+ return unobserve;
+ }
+ return undefined;
}, [groupBlock]);
return (
diff --git a/libs/components/editor-plugins/src/menu/left-menu/LeftMenuDraggable.tsx b/libs/components/editor-plugins/src/menu/left-menu/LeftMenuDraggable.tsx
index 996857c2ad..4f10f16fbe 100644
--- a/libs/components/editor-plugins/src/menu/left-menu/LeftMenuDraggable.tsx
+++ b/libs/components/editor-plugins/src/menu/left-menu/LeftMenuDraggable.tsx
@@ -184,6 +184,14 @@ export const LeftMenuDraggable: FC<LeftMenuProps> = props => {
return () => sub.unsubscribe();
}, [blockInfo, editor]);
+ useEffect(() => {
+ if (block?.block != null) {
+ const unobserve = block.block.onUpdate(() => setBlock(undefined));
+ return unobserve;
+ }
+ return undefined;
+ }, [block?.block]);
+
useEffect(() => {
const sub = lineInfo.subscribe(data => {
if (data == null) {