mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 11:22:19 +03:00
Updated global Modals to handle after close method
refs https://github.com/TryGhost/Product/issues/3349 - allows modals to call `afterClose` when removed in case the parent wants any action on modal close, like routing update
This commit is contained in:
parent
9ac6001031
commit
56fcba1d27
@ -28,6 +28,7 @@ export interface ModalProps {
|
||||
noPadding?: boolean;
|
||||
onOk?: () => void;
|
||||
onCancel?: () => void;
|
||||
afterClose?: () => void;
|
||||
children?: React.ReactNode;
|
||||
backDrop?: boolean;
|
||||
backDropClick?: boolean;
|
||||
@ -49,6 +50,7 @@ const Modal: React.FC<ModalProps> = ({
|
||||
onOk,
|
||||
okColor = 'black',
|
||||
onCancel,
|
||||
afterClose,
|
||||
children,
|
||||
backDrop = true,
|
||||
backDropClick = true,
|
||||
@ -66,7 +68,10 @@ const Modal: React.FC<ModalProps> = ({
|
||||
let buttons: ButtonProps[] = [];
|
||||
|
||||
const removeModal = () => {
|
||||
confirmIfDirty(dirty, () => modal.remove());
|
||||
confirmIfDirty(dirty, () => {
|
||||
modal.remove();
|
||||
afterClose?.();
|
||||
});
|
||||
};
|
||||
|
||||
if (!footer) {
|
||||
|
@ -36,6 +36,7 @@ export interface PreviewModalProps {
|
||||
|
||||
onCancel?: () => void;
|
||||
onOk?: () => void;
|
||||
afterClose?: () => void;
|
||||
onSelectURL?: (url: string) => void;
|
||||
onSelectDesktopView?: () => void;
|
||||
onSelectMobileView?: () => void;
|
||||
@ -65,6 +66,7 @@ export const PreviewModalContent: React.FC<PreviewModalProps> = ({
|
||||
|
||||
onCancel,
|
||||
onOk,
|
||||
afterClose,
|
||||
onSelectURL,
|
||||
onSelectDesktopView,
|
||||
onSelectMobileView
|
||||
@ -155,7 +157,10 @@ export const PreviewModalContent: React.FC<PreviewModalProps> = ({
|
||||
key: 'cancel-modal',
|
||||
label: cancelLabel,
|
||||
onClick: (onCancel ? onCancel : () => {
|
||||
confirmIfDirty(dirty, () => modal.remove());
|
||||
confirmIfDirty(dirty, () => {
|
||||
modal.remove();
|
||||
afterClose?.();
|
||||
});
|
||||
}),
|
||||
disabled: buttonsDisabled
|
||||
});
|
||||
@ -172,6 +177,7 @@ export const PreviewModalContent: React.FC<PreviewModalProps> = ({
|
||||
|
||||
return (
|
||||
<Modal
|
||||
afterClose={afterClose}
|
||||
footer={false}
|
||||
noPadding={true}
|
||||
size={size}
|
||||
|
Loading…
Reference in New Issue
Block a user