332398c99b82

fix TDZ in showAutofillSelector — captureKeydownRef now declared before renderLocked() so the locked inline popup stops stacking and autofocuses (v2.0.2)

time
2026-04-25 23:08 UTC · 6 months ago
machine
koh2
parent
489d21bdf37e
4 files manifest.firefox.json+1 −1manifest.json+1 −1package.json+1 −1src/content/inject.ts+13 −6
manifest.firefox.json+1 −1
@@ -1,7 +1,7 @@11 {22   "manifest_version": 3,33   "name": "Peach",4-  "version": "2.0.1",4+  "version": "2.0.2",55   "description": "Zero-knowledge password manager",66   "browser_specific_settings": {77     "gecko": {

view file

manifest.json+1 −1
@@ -1,7 +1,7 @@11 {22   "manifest_version": 3,33   "name": "Peach",4-  "version": "2.0.1",4+  "version": "2.0.2",55   "description": "Zero-knowledge password manager",66   "action": {77     "default_popup": "src/popup/index.html",

view file

package.json+1 −1
@@ -1,6 +1,6 @@11 {22   "name": "peach",3-  "version": "2.0.1",3+  "version": "2.0.2",44   "description": "Zero-knowledge password manager",55   "type": "module",66   "scripts": {

view file

src/content/inject.ts+13 −6
@@ -974,11 +974,6 @@974974   document.addEventListener("keydown", handleKeyDown);975975 976976   document.body.appendChild(host);977-  if (options.locked) {978-    renderLocked();979-  } else {980-    renderList();981-  }982977 983978   function updatePosition() {984979     const r = anchorEl.getBoundingClientRect();@@ -986,9 +981,21 @@986981     host.style.left = `${r.left + window.scrollX}px`;987982     host.style.width = `${Math.max(r.width, 260)}px`;988983   }984+  // These bindings are referenced from renderLocked()/dismiss() — they MUST985+  // be initialized before renderLocked() runs, or the synchronous assignment986+  // `captureKeydownRef = captureKeydown` inside renderLocked hits the TDZ987+  // and throws ReferenceError. The throw lands after the popup is rendered988+  // but before showAutofillSelector returns its dismiss handle, leaving an989+  // orphan host in the DOM (which is what caused the locked-popup stacking990+  // and missing autofocus on every click).991+  let captureKeydownRef: ((e: KeyboardEvent) => void) | null = null;989992   const stopObserving = observeAnchorPosition(anchorEl, updatePosition);990993 991-  let captureKeydownRef: ((e: KeyboardEvent) => void) | null = null;994+  if (options.locked) {995+    renderLocked();996+  } else {997+    renderList();998+  }992999 9931000   function dismiss(userAction = false) {9941001     stopObserving();

view file