Add afterClose param to reusabel context menu
authorAjay Bura <ajbura@gmail.com>
Thu, 13 Jan 2022 13:13:22 +0000 (18:43 +0530)
committerAjay Bura <ajbura@gmail.com>
Thu, 13 Jan 2022 13:13:22 +0000 (18:43 +0530)
Signed-off-by: Ajay Bura <ajbura@gmail.com>
src/app/atoms/context-menu/ReusableContextMenu.jsx
src/client/action/navigation.js
src/client/state/navigation.js

index f3a3c0d99493f41b374eda4d74e852815e6edcd2..59bdb1425af53308190625d31e330541304cf835 100644 (file)
@@ -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;
index 377a6158631497daa6141d944bfc8e57c2de6650..28aa0477d3b87a3cf3af4742260eea7ea8aebb90 100644 (file)
@@ -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,
   });
 }
index 674449f24103109f268427090e6bbf59ff8126ea..977cf7e97048dffb16eb19c6686486a87927c6c8 100644 (file)
@@ -146,6 +146,7 @@ class Navigation extends EventEmitter {
           action.placement,
           action.cords,
           action.render,
+          action.afterClose,
         );
       },
     };