From e67abae3e052fec42475f26407b85f57d50a5709 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Thu, 13 Jan 2022 18:43:22 +0530 Subject: [PATCH] Add afterClose param to reusabel context menu Signed-off-by: Ajay Bura --- src/app/atoms/context-menu/ReusableContextMenu.jsx | 7 +++++-- src/client/action/navigation.js | 3 ++- src/client/state/navigation.js | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app/atoms/context-menu/ReusableContextMenu.jsx b/src/app/atoms/context-menu/ReusableContextMenu.jsx index f3a3c0d..59bdb14 100644 --- a/src/app/atoms/context-menu/ReusableContextMenu.jsx +++ b/src/app/atoms/context-menu/ReusableContextMenu.jsx @@ -23,12 +23,14 @@ function ReusableContextMenu() { openerRef.current.style.height = `${cords.height}px`; openerRef.current.click(); } - const handleContextMenuOpen = (placement, cords, render) => { + const handleContextMenuOpen = (placement, cords, render, afterClose) => { if (key) { closeMenu(); return; } - setData({ placement, cords, render }); + setData({ + placement, cords, render, afterClose, + }); }; navigation.on(cons.events.navigation.REUSABLE_CONTEXT_MENU_OPENED, handleContextMenuOpen); return () => { @@ -44,6 +46,7 @@ function ReusableContextMenu() { key = Math.random(); return; } + data?.afterClose?.(); if (setData) setData(null); if (key === null) return; diff --git a/src/client/action/navigation.js b/src/client/action/navigation.js index 377a615..28aa047 100644 --- a/src/client/action/navigation.js +++ b/src/client/action/navigation.js @@ -103,11 +103,12 @@ export function openSearch(term) { }); } -export function openReusableContextMenu(placement, cords, render) { +export function openReusableContextMenu(placement, cords, render, afterClose) { appDispatcher.dispatch({ type: cons.actions.navigation.OPEN_REUSABLE_CONTEXT_MENU, placement, cords, render, + afterClose, }); } diff --git a/src/client/state/navigation.js b/src/client/state/navigation.js index 674449f..977cf7e 100644 --- a/src/client/state/navigation.js +++ b/src/client/state/navigation.js @@ -146,6 +146,7 @@ class Navigation extends EventEmitter { action.placement, action.cords, action.render, + action.afterClose, ); }, };