fix: allow modals to be submitted multiple times (#11843)

Fixes #11842.

The `once: true` was likely added to prevent multiple concurrent
submissions of the same form. This could still be worth preventing,
but I suspect it would require wrapping the supplied `onApprove`
callback with the corresponding logic, implemented manually, as I
am not aware of any native API to prevent concurrent executions of
callbacks.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11843
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Antonin Delpeuch <antonin@delpeuch.eu>
Co-committed-by: Antonin Delpeuch <antonin@delpeuch.eu>
This commit is contained in:
Antonin Delpeuch 2026-04-01 04:23:13 +02:00 committed by Gusted
commit 3763a88c67
2 changed files with 21 additions and 1 deletions

View file

@ -13,7 +13,7 @@ export function showModal(modalID: string, onApprove: () => void) {
modal.querySelector('.cancel')?.addEventListener('click', () => {
modal.close();
}, {once: true, passive: true});
modal.querySelector('.ok')?.addEventListener('click', onApprove, {once: true, passive: true});
modal.querySelector('.ok')?.addEventListener('click', onApprove, {passive: true});
// The modal is ready to be shown.
modal.showModal();