File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed
templates/plate-playground-template/src/components/ui Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments