Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Refresh autofill popup when conditional passkey event is received (#2177)

Leendert de Borst0414856a9191
diff --git a/apps/browser-extension/src/entrypoints/content.ts b/apps/browser-extension/src/entrypoints/content.ts
index e54937512..b8992573f 100644
--- a/apps/browser-extension/src/entrypoints/content.ts
+++ b/apps/browser-extension/src/entrypoints/content.ts
@@ -3,6 +3,7 @@
*/
import '@/entrypoints/contentScript/style.css';
+import { CONDITIONAL_PASSKEYS_UPDATED_EVENT } from '@/entrypoints/contentScript/ConditionalPasskey';
import { injectIcon, popupDebounceTimeHasPassed, validateInputField } from '@/entrypoints/contentScript/Form';
import { openAutofillPopup, openTotpPopup, removeExistingPopup, createUpgradeRequiredPopup } from '@/entrypoints/contentScript/Popup';
import { showSavePrompt, showAddUrlPrompt, isSavePromptVisible, updateSavePromptLogin, getPersistedSavePromptState, restoreSavePromptFromState, restoreAddUrlPromptFromState } from '@/entrypoints/contentScript/SavePrompt';
@@ -564,6 +565,21 @@ export default defineContentScript({
// Listen for input field focus in the main document
document.addEventListener('focusin', handleFocusIn);
+ /*
+ * A conditional passkey request can arrive after the page initially loaded (e.g. an
+ * autofocused login field). When passkeys become available, re-open the popup for
+ * the focused field so they appear immediately.
+ */
+ window.addEventListener(CONDITIONAL_PASSKEYS_UPDATED_EVENT, () => {
+ if (ctx.isInvalid) {
+ return;
+ }
+ const activeElement = document.activeElement;
+ if (activeElement) {
+ void showPopupForElement(activeElement);
+ }
+ });
+
// Check if currently something is focused, if so, apply check for that element
const currentFocusedElement = document.activeElement;
if (currentFocusedElement) {