fix: convert sleep to raf

This commit is contained in:
LuciNyan 2022-08-17 21:49:43 +08:00
parent 67f0a2516b
commit 3a4bc73d38

View File

@ -4,7 +4,7 @@ import {
PluginHooks,
Virgo,
} from '@toeverything/components/editor-core';
import { Point, sleep } from '@toeverything/utils';
import { Point } from '@toeverything/utils';
import { GroupDirection } from '@toeverything/framework/virgo';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { DragItem } from './DragItem';
@ -154,10 +154,11 @@ export const GroupMenu = function ({ editor, hooks }: GroupMenuProps) {
setShowMenu(false);
if (groupBlock) {
const unobserve = groupBlock.onUpdate(async () => {
await sleep();
const unobserve = groupBlock.onUpdate(() => {
requestAnimationFrame(() => {
setGroupBlock(null);
});
});
return unobserve;
}
return undefined;