Fixed modal footer bug in AdminX

refs. https://github.com/TryGhost/Team/issues/3432
This commit is contained in:
Peter Zimon 2023-06-13 12:16:19 +02:00
parent 58f51a1838
commit 09b404acd2
2 changed files with 28 additions and 27 deletions

View File

@ -25,7 +25,7 @@ const ConfirmationModal: React.FC<ConfirmationModalProps> = ({
okColor = 'black', okColor = 'black',
onCancel, onCancel,
onOk, onOk,
customFooter = false customFooter
}) => { }) => {
const modal = useModal(); const modal = useModal();
const [taskState, setTaskState] = useState<'running' | ''>(''); const [taskState, setTaskState] = useState<'running' | ''>('');

View File

@ -138,10 +138,6 @@ const Modal: React.FC<ModalProps> = ({
((size === 'full' || size === 'bleed') && 'grow') ((size === 'full' || size === 'bleed') && 'grow')
); );
if (!footer) {
contentClasses += ' pb-0 ';
}
const handleBackdropClick = (e: React.MouseEvent<HTMLDivElement>) => { const handleBackdropClick = (e: React.MouseEvent<HTMLDivElement>) => {
if (e.target === e.currentTarget && backDropClick) { if (e.target === e.currentTarget && backDropClick) {
modal.remove(); modal.remove();
@ -152,31 +148,36 @@ const Modal: React.FC<ModalProps> = ({
width: size + 'px' width: size + 'px'
} : {}; } : {};
const footerContent = ( let footerContent;
<div className={footerClasses}> if (footer) {
<div> footerContent = footer;
{leftButtonLabel && } else if (footer === false) {
<Button label={leftButtonLabel} link={true} /> contentClasses += ' pb-0 ';
} } else {
footerContent = (
<div className={footerClasses}>
<div>
{leftButtonLabel &&
<Button label={leftButtonLabel} link={true} />
}
</div>
<div className='flex gap-3'>
<ButtonGroup buttons={buttons}/>
</div>
</div> </div>
<div className='flex gap-3'>
<ButtonGroup buttons={buttons}/>
</div>
</div>
);
if (footer === undefined) {
footer = (stickyFooter ?
<StickyFooter height={84}>
{footerContent}
</StickyFooter>
:
<>
{footerContent}
</>
); );
} }
footerContent = (stickyFooter ?
<StickyFooter height={84}>
{footerContent}
</StickyFooter>
:
<>
{footerContent}
</>
);
return ( return (
<div className={backdropClasses} id='modal-backdrop' onClick={handleBackdropClick}> <div className={backdropClasses} id='modal-backdrop' onClick={handleBackdropClick}>
<div className={clsx( <div className={clsx(
@ -190,7 +191,7 @@ const Modal: React.FC<ModalProps> = ({
{children} {children}
</div> </div>
</div> </div>
{footer} {footerContent}
</section> </section>
</div> </div>
); );