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

* Only allow one close draft confirmation at a time

* lint
zio/stable
Ollie H 2023-05-11 08:38:10 -07:00 committed by GitHub
parent c2fb4d4b4b
commit 0192923ef3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

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(() => {