fix(plugin): hide left menu when block change

This commit is contained in:
austaras 2022-08-10 15:45:58 +08:00
parent ffdf247517
commit 00f5f239b2
2 changed files with 14 additions and 0 deletions

View File

@ -168,6 +168,12 @@ export const GroupMenu = function ({ editor, hooks }: GroupMenuProps) {
useEffect(() => { useEffect(() => {
setShowMenu(false); setShowMenu(false);
if (groupBlock) {
const unobserve = groupBlock.onUpdate(() => setGroupBlock(null));
return unobserve;
}
return undefined;
}, [groupBlock]); }, [groupBlock]);
return ( return (

View File

@ -184,6 +184,14 @@ export const LeftMenuDraggable: FC<LeftMenuProps> = props => {
return () => sub.unsubscribe(); return () => sub.unsubscribe();
}, [blockInfo, editor]); }, [blockInfo, editor]);
useEffect(() => {
if (block?.block != null) {
const unobserve = block.block.onUpdate(() => setBlock(undefined));
return unobserve;
}
return undefined;
}, [block?.block]);
useEffect(() => { useEffect(() => {
const sub = lineInfo.subscribe(data => { const sub = lineInfo.subscribe(data => {
if (data == null) { if (data == null) {