Skip to content

Commit

Permalink
Improve icon inject (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
lanedirt committed Feb 13, 2025
1 parent 390c774 commit 867b37a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
13 changes: 6 additions & 7 deletions browser-extensions/chrome/src/contentScript/Form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,11 @@ export function injectIcon(input: HTMLInputElement): void {

icon.setAttribute('data-icon-for', input.id);

icon.addEventListener('click', () => {
icon.addEventListener('click', (e: MouseEvent) => {
e.preventDefault();
e.stopPropagation();
// Prevent the input from losing focus when clicking the icon
setTimeout(() => input.focus(), 0);
openAutofillPopup(input);
});

Expand All @@ -208,12 +212,7 @@ export function injectIcon(input: HTMLInputElement): void {
/**
* Remove icon when input loses focus, except when clicking the icon
*/
const handleBlur = (e: FocusEvent) : void => {
// Don't remove if clicking the icon itself
if (e.relatedTarget === icon) {
return;
}

const handleBlur = () : void => {
// Fade out and remove icon
icon.style.opacity = '0';
setTimeout(() => {
Expand Down
6 changes: 0 additions & 6 deletions browser-extensions/chrome/src/contentScript/Popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,6 @@ export function createAutofillPopup(input: HTMLInputElement, credentials: Creden
// Add the event listener for clicking outside
document.addEventListener('mousedown', handleClickOutside);
document.body.appendChild(popup);

// When creating the popup, also (re)create the icon so it stays visible.
injectIcon(input);
}

/**
Expand Down Expand Up @@ -521,9 +518,6 @@ export function createVaultLockedPopup(input: HTMLInputElement): void {
}, 100);

document.body.appendChild(popup);

// When creating the popup, also (re)create the icon so it stays visible.
injectIcon(input);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/AliasVault.Client/wwwroot/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
==========================================================================================================
AliasVault - Free open-source password manager.
AliasVault - Free open-source password and (email) alias manager.
Build (UTC): @BuildVersion
Source code: https://github.com/lanedirt/AliasVault
Expand Down

0 comments on commit 867b37a

Please sign in to comment.