diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-09-21 19:53:33 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-09-21 19:53:33 +0200 |
| commit | 9f3445d03f106ee3ebd8b4b1bd546a08d9169af7 (patch) | |
| tree | fabae2b4c9e2fee75a73c5ba1479075be908a584 /packages/meshbay-hub/src/meshbay_hub/static/files-app.js | |
| parent | 24b563d0073849d0ba74c3fce9822a70c98e9d9f (diff) | |
| download | meshbay-9f3445d03f106ee3ebd8b4b1bd546a08d9169af7.tar.gz | |
fix: ask in the page instead of native confirm/alert
A native confirm() or alert() leaves the desktop client unable to type
until the window is refocused. ask.js draws both in the page; the SPA
test now bans all three browser dialogs.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/files-app.js')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/static/files-app.js | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/files-app.js b/packages/meshbay-hub/src/meshbay_hub/static/files-app.js index 3f4212e..6aabea3 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/files-app.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/files-app.js @@ -2,6 +2,7 @@ import { html, useState, useEffect, useRef, useCallback, } from './vendor/htm-preact.js'; import { t } from './i18n.js'; +import { ask } from './ask.js'; import { Icon } from './icon.js'; import { entriesUnder } from './zipstream.js'; import { transfers } from './transfers.js'; @@ -280,9 +281,10 @@ function FilesPanel({ * The name comes from a field in the toolbar rather than `window.prompt`, * which **throws** in Electron — "prompt() is not supported" — and threw * outside this function's try, so clicking the button did nothing at all: - * no folder, no error, nothing in the interface to react to. `confirm()` and - * `alert()` do work there and are used elsewhere; `prompt` is the one - * Chromium leaves to the embedder and Electron declines to implement. + * no folder, no error, nothing in the interface to react to. `prompt` is the + * one Chromium leaves to the embedder and Electron declines to implement; + * `confirm()` and `alert()` open but leave the window unable to type after + * them, which is why `ask.js` exists. * * An inline field is better anyway — it can show the refusal next to the * input instead of after the dialog has closed. @@ -636,10 +638,10 @@ function FilesPanel({ }), { disabled: selectedDirs.length === 0 })} ${mayEverDelete && !readOnly && action('trash', deletableCount ? t('group.delete_n', { n: deletableCount }) : t('group.delete'), - () => { + async () => { const names = [...deletableFiles.map(e => e.name), ...(operatorPaired ? selectedDirs : [])]; - if (!confirm(t('group.delete_n_confirm', { n: names.length, + if (!await ask(t('group.delete_n_confirm', { n: names.length, names: names.join(', ') }))) return; run(() => { for (const e of deletableFiles) deleteFile(e); |