Skip to content

Commit 2a284be

Browse files
fix
1 parent b48bb9b commit 2a284be

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

apps/www/src/registry/ui/block-context-menu.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export function BlockContextMenu({ children }: { children: React.ReactNode }) {
3131
const isTouch = useIsTouchDevice();
3232
const [readOnly] = usePlateState('readOnly');
3333
const openId = usePluginOption(BlockMenuPlugin, 'openId');
34-
const isOpen = openId === BLOCK_CONTEXT_MENU_ID;
34+
const isOpen = React.useMemo(() => {
35+
return openId === BLOCK_CONTEXT_MENU_ID;
36+
}, [openId]);
3537

3638
const handleTurnInto = React.useCallback(
3739
(type: string) => {
@@ -68,10 +70,7 @@ export function BlockContextMenu({ children }: { children: React.ReactNode }) {
6870
<ContextMenu
6971
onOpenChange={(open) => {
7072
if (!open) {
71-
// prevent unselect the block selection
72-
setTimeout(() => {
73-
api.blockMenu.hide();
74-
}, 0);
73+
api.blockMenu.hide();
7574
}
7675
}}
7776
modal={false}

templates/plate-playground-template/src/components/ui/block-context-menu.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export function BlockContextMenu({ children }: { children: React.ReactNode }) {
3131
const isTouch = useIsTouchDevice();
3232
const [readOnly] = usePlateState('readOnly');
3333
const openId = usePluginOption(BlockMenuPlugin, 'openId');
34-
const isOpen = openId === BLOCK_CONTEXT_MENU_ID;
34+
const isOpen = React.useMemo(() => {
35+
return openId === BLOCK_CONTEXT_MENU_ID;
36+
}, [openId]);
3537

3638
const handleTurnInto = React.useCallback(
3739
(type: string) => {
@@ -68,10 +70,7 @@ export function BlockContextMenu({ children }: { children: React.ReactNode }) {
6870
<ContextMenu
6971
onOpenChange={(open) => {
7072
if (!open) {
71-
// prevent unselect the block selection
72-
setTimeout(() => {
73-
api.blockMenu.hide();
74-
}, 0);
73+
api.blockMenu.hide();
7574
}
7675
}}
7776
modal={false}

0 commit comments

Comments
 (0)