Add condition to modal

This way we prevent unwanted data loading, invisible updates
and visual artifacts when the modal isn't visible.

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2022-01-06 22:36:28 +01:00
parent 89eac12a38
commit 9500887ee6

View file

@ -48,23 +48,25 @@ export const CommonModal: React.FC<CommonModalProps> = ({
}, [title, titleIsI18nKey])
return (
<Modal
{...cypressId(props)}
show={show}
onHide={onHide}
animation={true}
dialogClassName={`text-dark ${additionalClasses ?? ''}`}
size={modalSize}>
<Modal.Header closeButton={!!showCloseButton}>
<Modal.Title>
<ShowIf condition={!!titleIcon}>
<ForkAwesomeIcon icon={titleIcon as IconName} />
&nbsp;
</ShowIf>
{titleElement}
</Modal.Title>
</Modal.Header>
{children}
</Modal>
<ShowIf condition={show}>
<Modal
{...cypressId(props)}
show={show}
onHide={onHide}
animation={true}
dialogClassName={`text-dark ${additionalClasses ?? ''}`}
size={modalSize}>
<Modal.Header closeButton={!!showCloseButton}>
<Modal.Title>
<ShowIf condition={!!titleIcon}>
<ForkAwesomeIcon icon={titleIcon as IconName} />
&nbsp;
</ShowIf>
{titleElement}
</Modal.Title>
</Modal.Header>
{children}
</Modal>
</ShowIf>
)
}