Skip to content

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

Add enter to submit for custom alias form (#758)

Leendert de Borstd7be5fc30848
diff --git a/browser-extension/src/entrypoints/contentScript/Popup.ts b/browser-extension/src/entrypoints/contentScript/Popup.ts
index 10314ea56..955fa3e9b 100644
--- a/browser-extension/src/entrypoints/contentScript/Popup.ts
+++ b/browser-extension/src/entrypoints/contentScript/Popup.ts
@@ -962,7 +962,10 @@ export async function createAliasCreationPopup(defaultName: string, rootContaine
}
});
- customSaveBtn.addEventListener('click', () => {
+ /**
+ * Handle custom save button click.
+ */
+ const handleCustomSave = () : void => {
const serviceName = customInput.value.trim();
if (serviceName) {
const email = customEmail.value.trim();
@@ -1027,7 +1030,23 @@ export async function createAliasCreationPopup(defaultName: string, rootContaine
customPassword: passwordPreview.value
});
}
- });
+ }
+
+ customSaveBtn.addEventListener('click', handleCustomSave);
+
+ /**
+ * Handle custom form input enter key press to submit the form.
+ */
+ const handleCustomEnter = (e: KeyboardEvent) : void => {
+ if (e.key === 'Enter') {
+ handleCustomSave();
+ }
+ };
+
+ customInput.addEventListener('keyup', handleCustomEnter);
+ customEmail.addEventListener('keyup', handleCustomEnter);
+ customUsername.addEventListener('keyup', handleCustomEnter);
+ passwordPreview.addEventListener('keyup', handleCustomEnter);
// Handle cancel buttons
cancelBtn.addEventListener('click', () => {
@@ -1051,34 +1070,6 @@ export async function createAliasCreationPopup(defaultName: string, rootContaine
}
});
- customInput.addEventListener('keyup', (e) => {
- if (e.key === 'Enter') {
- const serviceName = customInput.value.trim();
- if (serviceName) {
- const email = customEmail.value.trim();
- const username = customUsername.value.trim();
- const hasDefaultEmail = customEmail.classList.contains('av-create-popup-input-default');
- const hasDefaultUsername = customUsername.classList.contains('av-create-popup-input-default');
-
- // If using default values, use the dataset values
- const finalEmail = hasDefaultEmail ? customEmail.dataset.defaultValue : email;
- const finalUsername = hasDefaultUsername ? customUsername.dataset.defaultValue : username;
-
- if (!finalEmail && !finalUsername) {
- return;
- }
-
- closePopup({
- serviceName,
- isCustomCredential: true,
- customEmail: finalEmail,
- customUsername: finalUsername,
- customPassword: passwordPreview.value
- });
- }
- }
- });
-
/**
* Handle click outside.
*/