fix: close only the drawer opening whose draft discard was awaited

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ViTUkt4czrvZdxdWwxqRAQ
This commit is contained in:
Diego Imbert
2026-09-13 06:09:01 +02:00
co-authored by Claude Opus 5
parent db791f0493
commit c51a932eed
@@ -176,8 +176,12 @@
getDeployed={() => resourceEditor?.localDraftDeployed()}
getCurrent={() => resourceEditor?.localDraftCurrent()}
onDiscard={async () => {
// A draft-only resource is its draft: discarding it leaves nothing to show.
if (await resourceEditor?.discardLocalDraft()) drawer?.closeDrawer()
// A draft-only resource is its draft: discarding it leaves nothing to show. Close
// only the opening that asked for it — the discard is awaited, and another resource
// may have been opened over this drawer in the meantime.
const opening = session
if ((await resourceEditor?.discardLocalDraft()) && session === opening)
drawer?.closeDrawer()
}}
disabled={!canWriteSelected}
/>