Only allow one close draft confirmation at a time (#611)

* Only allow one close draft confirmation at a time

* lint
This commit is contained in:
Ollie H
2023-05-11 08:38:10 -07:00
committed by GitHub
parent c2fb4d4b4b
commit 0192923ef3
+8 -2
View File
@@ -91,7 +91,13 @@ export const ComposePost = observer(function ComposePost({
const onEscape = useCallback(
(e: KeyboardEvent) => {
if (e.key === 'Escape') {
store.shell.openModal({
const {shell} = store
if (shell.activeModals.some(modal => modal.name === 'confirm')) {
store.shell.closeModal()
}
shell.openModal({
name: 'confirm',
title: 'Cancel draft',
onPressConfirm: onClose,
@@ -102,7 +108,7 @@ export const ComposePost = observer(function ComposePost({
})
}
},
[store.shell, onClose],
[store, onClose],
)
useEffect(() => {