fix(settings-ui): replace the native JS dialogs, which do nothing on macOS - #18
Open
maerlin wants to merge 1 commit into
Open
fix(settings-ui): replace the native JS dialogs, which do nothing on macOS#18maerlin wants to merge 1 commit into
maerlin wants to merge 1 commit into
Conversation
…macOS Rename, Remove, Change password, Disable lock, and the lock screen's reset link all went through window.prompt, confirm or alert. WKWebView shows a JavaScript dialog only when the host implements the matching WKUIDelegate panel method, and wry implements none of them. On macOS prompt() therefore returns null, confirm() returns false, and alert() draws nothing, with no error anywhere. Each of those controls was a dead button. Windows (WebView2) and Linux (WebKitGTK) answer the calls natively, which is why the same code works there. Add settings-ui/dialog.js and dialog.css: alert, confirm and prompt built from page elements, with the same shape as the natives but async (`await Dlg.confirm(...)`). They close on Escape or on a click outside, keep Tab inside the dialog, restore focus to whatever opened them, and refuse an empty required field instead of resolving an empty string. Passwords are passed through untrimmed. The settings window and the lock screen both load them, and every call site moves over. The error paths that used alert() now say which action failed. dialog.test.mjs checks the resolve semantics against a stubbed DOM and runs in CI beside the other zero-dependency node tests. Without it, a regression here stays invisible on the Linux and Windows runners and surfaces only as a dead button on macOS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Five controls in the settings UI do nothing at all on macOS:
prompt()null, nothing drawnconfirm()false, nothing drawnprompt()nullprompt()nullconfirm()falseEvery
alert(...)error path is swallowed the same way, so failures fromadd_account,lock_app,set_biometric_enabledand the lock options are invisible.The cause is not in this repo. WKWebView shows a JavaScript dialog only if the host implements the matching
WKUIDelegatepanel method (runJavaScriptTextInputPanelWithPrompt:,runJavaScriptConfirmPanelWithMessage:,runJavaScriptAlertPanelWithMessage:). wry implements none of them:src/wkwebview/class/wry_web_view_ui_delegate.rscovers only the open-file panel, media-capture permission, andcreateWebViewWithConfiguration. WebKit's documented behaviour when the delegate omits these is to complete immediately with the default value, without drawing anything and without raising an error.Windows (WebView2) and Linux (WebKitGTK) answer these calls natively, which is why the same code works everywhere else and the breakage is macOS-only.
Change
settings-ui/dialog.jsanddialog.css:alert,confirmandpromptbuilt from page elements. Same shape as the natives, but async, so call sites becomeawait Dlg.confirm(...)instead ofif (confirm(...)).Behaviour:
promptcancelling (null) stays distinguishable from an empty answer.window.promptdoes not trim, and trimming would silently mangle a password with edge whitespace.index.htmlandlock.htmlcan load them without extending either page's sheet.Every call site moves over, and the error paths that used
alert()now name the action that failed ("Could not rename", "Could not disable the lock") instead of showing a bare message.Testing
settings-ui/dialog.test.mjs: 9 cases, 25 assertions, run against a stubbed DOM in the same zero-dependency style asbridge.test.mjsandcomboToAccelerator.test.mjs. Added as a step incheck.yml.The test exists because of the failure mode itself: a regression here is invisible on the Linux and Windows CI runners and surfaces only as a dead button on macOS.
Also verified by hand in a release build on macOS 15 (Apple Silicon): rename, remove, change password, disable lock, and the reset link all work now.
Alternative considered
tauri-plugin-dialoggives nativeask/message, but has no text-input prompt, so rename and the password flows would still need in-page UI. Doing all of them one way keeps the behaviour consistent across the three platforms and adds no dependency.