mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05: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
2 changed files with 13 additions and 2 deletions
|
@ -28,6 +28,7 @@ export interface ModalProps {
|
||||||
noPadding?: boolean;
|
noPadding?: boolean;
|
||||||
onOk?: () => void;
|
onOk?: () => void;
|
||||||
onCancel?: () => void;
|
onCancel?: () => void;
|
||||||
|
afterClose?: () => void;
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
backDrop?: boolean;
|
backDrop?: boolean;
|
||||||
backDropClick?: boolean;
|
backDropClick?: boolean;
|
||||||
|
@ -49,6 +50,7 @@ const Modal: React.FC<ModalProps> = ({
|
||||||
onOk,
|
onOk,
|
||||||
okColor = 'black',
|
okColor = 'black',
|
||||||
onCancel,
|
onCancel,
|
||||||
|
afterClose,
|
||||||
children,
|
children,
|
||||||
backDrop = true,
|
backDrop = true,
|
||||||
backDropClick = true,
|
backDropClick = true,
|
||||||
|
@ -66,7 +68,10 @@ const Modal: React.FC<ModalProps> = ({
|
||||||
let buttons: ButtonProps[] = [];
|
let buttons: ButtonProps[] = [];
|
||||||
|
|
||||||
const removeModal = () => {
|
const removeModal = () => {
|
||||||
confirmIfDirty(dirty, () => modal.remove());
|
confirmIfDirty(dirty, () => {
|
||||||
|
modal.remove();
|
||||||
|
afterClose?.();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!footer) {
|
if (!footer) {
|
||||||
|
|
|
@ -36,6 +36,7 @@ export interface PreviewModalProps {
|
||||||
|
|
||||||
onCancel?: () => void;
|
onCancel?: () => void;
|
||||||
onOk?: () => void;
|
onOk?: () => void;
|
||||||
|
afterClose?: () => void;
|
||||||
onSelectURL?: (url: string) => void;
|
onSelectURL?: (url: string) => void;
|
||||||
onSelectDesktopView?: () => void;
|
onSelectDesktopView?: () => void;
|
||||||
onSelectMobileView?: () => void;
|
onSelectMobileView?: () => void;
|
||||||
|
@ -65,6 +66,7 @@ export const PreviewModalContent: React.FC<PreviewModalProps> = ({
|
||||||
|
|
||||||
onCancel,
|
onCancel,
|
||||||
onOk,
|
onOk,
|
||||||
|
afterClose,
|
||||||
onSelectURL,
|
onSelectURL,
|
||||||
onSelectDesktopView,
|
onSelectDesktopView,
|
||||||
onSelectMobileView
|
onSelectMobileView
|
||||||
|
@ -155,7 +157,10 @@ export const PreviewModalContent: React.FC<PreviewModalProps> = ({
|
||||||
key: 'cancel-modal',
|
key: 'cancel-modal',
|
||||||
label: cancelLabel,
|
label: cancelLabel,
|
||||||
onClick: (onCancel ? onCancel : () => {
|
onClick: (onCancel ? onCancel : () => {
|
||||||
confirmIfDirty(dirty, () => modal.remove());
|
confirmIfDirty(dirty, () => {
|
||||||
|
modal.remove();
|
||||||
|
afterClose?.();
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
disabled: buttonsDisabled
|
disabled: buttonsDisabled
|
||||||
});
|
});
|
||||||
|
@ -172,6 +177,7 @@ export const PreviewModalContent: React.FC<PreviewModalProps> = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
|
afterClose={afterClose}
|
||||||
footer={false}
|
footer={false}
|
||||||
noPadding={true}
|
noPadding={true}
|
||||||
size={size}
|
size={size}
|
||||||
|
|
Loading…
Add table
Reference in a new issue