Skip to content

Commit fab1357

Browse files
committed
Make on_close optional in AutoClosingModal and update rendering logic to handle its absence
- make on_close optional, if not given, don't render the footer button
1 parent 7710db5 commit fab1357

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

‎packages/ui/src/components/editor/panel/modals/AutoClosingModal/AutoClosingModal.tsx‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type Props = {
77
title: string
88
duration: number
99
type: ModalIconType
10-
on_close: () => void
10+
on_close?: () => void
1111
}
1212

1313
export const AutoClosingModal: React.FC<Props> = (props) => {
@@ -16,7 +16,7 @@ export const AutoClosingModal: React.FC<Props> = (props) => {
1616
useEffect(() => {
1717
set_is_filling(true)
1818
const timeout = setTimeout(() => {
19-
props.on_close()
19+
props.on_close?.()
2020
}, props.duration)
2121

2222
return () => {
@@ -29,7 +29,7 @@ export const AutoClosingModal: React.FC<Props> = (props) => {
2929
onKeyDown={(e) => {
3030
if (e.key == 'Escape') {
3131
e.stopPropagation()
32-
props.on_close()
32+
props.on_close?.()
3333
}
3434
}}
3535
>
@@ -49,9 +49,11 @@ export const AutoClosingModal: React.FC<Props> = (props) => {
4949
}
5050
on_background_click={props.on_close}
5151
footer_slot={
52-
<Button on_click={props.on_close} is_focused={true}>
53-
Close
54-
</Button>
52+
props.on_close ? (
53+
<Button on_click={props.on_close} is_focused={true}>
54+
Close
55+
</Button>
56+
) : undefined
5557
}
5658
/>
5759
</div>

0 commit comments

Comments
 (0)