From cf1f966f60db23dcda83eb68b0097b48ac8d6ed5 Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Sun, 26 Oct 2025 12:07:17 -0400 Subject: [PATCH] Fix edit modal error after successful submit --- js/ui/components/EditModal.js | 10 +++++-- tests/edit-modal-submit-state.test.mjs | 39 ++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/js/ui/components/EditModal.js b/js/ui/components/EditModal.js index ba3eda16..1229f665 100644 --- a/js/ui/components/EditModal.js +++ b/js/ui/components/EditModal.js @@ -791,12 +791,16 @@ export class EditModal { return; } - if (!this.activeVideo || !this.root) { - this.showError("No video selected for editing."); + const contextVideo = this.activeVideo || this.pendingSubmitVideo || null; + + if (!contextVideo || !this.root) { + if (this.isVisible) { + this.showError("No video selected for editing."); + } return; } - this.setSubmitState({ pending: true, video: this.activeVideo }); + this.setSubmitState({ pending: true, video: contextVideo }); const fieldValue = (key) => { const input = this.fields[key]; diff --git a/tests/edit-modal-submit-state.test.mjs b/tests/edit-modal-submit-state.test.mjs index 59f8d8c5..97f3d7fd 100644 --- a/tests/edit-modal-submit-state.test.mjs +++ b/tests/edit-modal-submit-state.test.mjs @@ -191,3 +191,42 @@ test('ignores additional submissions while pending without spurious errors', asy modal.setSubmitState({ pending: false }); }); + +test('does not show missing video error after modal closes', async () => { + const errorMessages = []; + const modal = createModal({ + showError: (message) => { + if (message) { + errorMessages.push(message); + } + }, + }); + + await modal.load({ container }); + + const video = { + id: 'video2', + pubkey: 'pubkey2', + title: 'Another video', + url: 'https://example.com/another.mp4', + }; + + await modal.open(video); + + modal.submit(); + + assert.equal(errorMessages.includes('No video selected for editing.'), false); + + modal.setSubmitState({ pending: false }); + modal.close(); + + assert.equal(modal.isVisible, false, 'modal should be hidden after close'); + + modal.submit(); + + assert.equal( + errorMessages.includes('No video selected for editing.'), + false, + 'should not surface missing video error when closed', + ); +});