Keep invoice modal open if focus is lost
This commit is contained in:
parent
7dda8a1e01
commit
6b4b5023f6
|
@ -21,6 +21,7 @@ export function useShowModal () {
|
||||||
|
|
||||||
export default function useModal () {
|
export default function useModal () {
|
||||||
const [modalContent, setModalContent] = useState(null)
|
const [modalContent, setModalContent] = useState(null)
|
||||||
|
const [modalOptions, setModalOptions] = useState(null)
|
||||||
|
|
||||||
const onClose = useCallback(() => {
|
const onClose = useCallback(() => {
|
||||||
setModalContent(null)
|
setModalContent(null)
|
||||||
|
@ -31,7 +32,7 @@ export default function useModal () {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Modal onHide={onClose} show={!!modalContent}>
|
<Modal onHide={modalOptions?.keepOpen ? null : onClose} show={!!modalContent}>
|
||||||
<div className='modal-close' onClick={onClose}>X</div>
|
<div className='modal-close' onClick={onClose}>X</div>
|
||||||
<Modal.Body>
|
<Modal.Body>
|
||||||
{modalContent}
|
{modalContent}
|
||||||
|
@ -41,7 +42,8 @@ export default function useModal () {
|
||||||
}, [modalContent, onClose])
|
}, [modalContent, onClose])
|
||||||
|
|
||||||
const showModal = useCallback(
|
const showModal = useCallback(
|
||||||
(getContent) => {
|
(getContent, options) => {
|
||||||
|
setModalOptions(options)
|
||||||
setModalContent(getContent(onClose))
|
setModalContent(getContent(onClose))
|
||||||
},
|
},
|
||||||
[onClose]
|
[onClose]
|
||||||
|
|
|
@ -58,7 +58,7 @@ export const useAnonymous = (fn, options = defaultOptions) => {
|
||||||
}, 2000)
|
}, 2000)
|
||||||
}
|
}
|
||||||
} successVerb='received'
|
} successVerb='received'
|
||||||
/>
|
/>, { keepOpen: true }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}, [invoice?.id])
|
}, [invoice?.id])
|
||||||
|
|
Loading…
Reference in New Issue