fix(health): Fix button must not act when the switch was cancelled

Vault health → Fix on entry B while the editor is open and dirty on entry A:
the discard prompt appears, Cancel keeps A open — but openEntryForFix carried
on regardless. It unmasked A's password to cleartext, selected it, and pulsed
the Generate button (the blinking). Wrong entry, and it revealed a password
the user never asked to see.

openSlideOver was void, so callers couldn't tell a cancelled switch from a
successful one. It now returns false when it bails (discard cancelled, entry
not found) and true once the panel actually shows the requested entry;
openEntryForFix checks it before touching the password field.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
r-zakarya
2026-07-25 16:22:50 +01:00
parent 660f495649
commit 8b02a5650a
2 changed files with 10 additions and 3 deletions
+4 -1
View File
@@ -93,7 +93,10 @@ function healthScoreBand(score) {
// dismiss. Auto-opening the generator modal hid the entry context and
// forced an extra Save click — worse UX than this lighter nudge.
async function openEntryForFix(entryId) {
await openSlideOver(entryId);
// Bail if the editor didn't actually switch (user cancelled the discard
// prompt): the steps below would unmask + select the password of whatever
// entry is still open, and pulse Generate on it — the wrong entry.
if (!(await openSlideOver(entryId))) return;
const pwd = document.getElementById('soPassword');
if (pwd) {
pwd.type = 'text'; // unmask so the user sees what they're replacing