From 307df9c23ad9ad786e042ec09d5a3f3e28f30b84 Mon Sep 17 00:00:00 2001 From: mwiegand Date: Sun, 17 May 2026 15:51:47 +0200 Subject: [PATCH] feat(files): migrate dialogs (new-folder, delete, conflict) to dialogs.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Step 3/12 of docs/superpowers/plans/2026-05-17-files-overlay-rewrite.md. dialogs.js owns the three inline modals that surround the file manager: * #files-new-folder-modal — "+ folder" / mkdir prompt * #files-delete-modal — delete-confirm for files and folders * #files-conflict-modal — overwrite / keep-both / cancel choice Pattern change: the legacy file used clone-and-rebind (replaceWith(cloneNode(true)) + fresh addEventListener) to drop stale state-bearing click listeners between dialog opens. dialogs.js replaces that with a single delegated listener per dialog, reading per-dialog state from module-scope nullable variables (conflictState, deleteState, newFolderState). The state is set when the dialog opens and cleared on the 'close' event so dismissals don't leave stale references. Listener attaches once per page load. Dialog opens go through window.modals.openInline()/closeInline() instead of dialog.showModal()/close() directly, completing the inline- modal convention from commit c51089d. askConflict now resolves to "cancel" on any dismissal (Esc, backdrop, programmatic close) thanks to the 'close' event handler — the legacy version left the promise pending forever in those paths. Verified live: closeInline() on an open conflict dialog resolves the pending askConflict promise to "cancel". Action-registry dispatch: dialogs.js registers "new-folder" and "delete" handlers into __filesOverlay. Combined with editor.js's registration of "new-file" and "edit" (Step 2), only "zip" remains in the legacy click switch (pure URL navigation, no module dependency). Cross-module exposure: askConflict moves from files-overlay.js to dialogs.js; both set __filesOverlay.askConflict, but dialogs.js wins by document order (it loads before legacy via the + {% endif %} {% endblock %}