Add afterClose param to reusabel context menu
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
@@ -23,12 +23,14 @@ function ReusableContextMenu() {
|
|||||||
openerRef.current.style.height = `${cords.height}px`;
|
openerRef.current.style.height = `${cords.height}px`;
|
||||||
openerRef.current.click();
|
openerRef.current.click();
|
||||||
}
|
}
|
||||||
const handleContextMenuOpen = (placement, cords, render) => {
|
const handleContextMenuOpen = (placement, cords, render, afterClose) => {
|
||||||
if (key) {
|
if (key) {
|
||||||
closeMenu();
|
closeMenu();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setData({ placement, cords, render });
|
setData({
|
||||||
|
placement, cords, render, afterClose,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
navigation.on(cons.events.navigation.REUSABLE_CONTEXT_MENU_OPENED, handleContextMenuOpen);
|
navigation.on(cons.events.navigation.REUSABLE_CONTEXT_MENU_OPENED, handleContextMenuOpen);
|
||||||
return () => {
|
return () => {
|
||||||
@@ -44,6 +46,7 @@ function ReusableContextMenu() {
|
|||||||
key = Math.random();
|
key = Math.random();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
data?.afterClose?.();
|
||||||
if (setData) setData(null);
|
if (setData) setData(null);
|
||||||
|
|
||||||
if (key === null) return;
|
if (key === null) return;
|
||||||
|
|||||||
@@ -103,11 +103,12 @@ export function openSearch(term) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function openReusableContextMenu(placement, cords, render) {
|
export function openReusableContextMenu(placement, cords, render, afterClose) {
|
||||||
appDispatcher.dispatch({
|
appDispatcher.dispatch({
|
||||||
type: cons.actions.navigation.OPEN_REUSABLE_CONTEXT_MENU,
|
type: cons.actions.navigation.OPEN_REUSABLE_CONTEXT_MENU,
|
||||||
placement,
|
placement,
|
||||||
cords,
|
cords,
|
||||||
render,
|
render,
|
||||||
|
afterClose,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ class Navigation extends EventEmitter {
|
|||||||
action.placement,
|
action.placement,
|
||||||
action.cords,
|
action.cords,
|
||||||
action.render,
|
action.render,
|
||||||
|
action.afterClose,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user