mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 00:03:56 +00:00
[PM-5189] Refining how we handle fading in the inline menu elements
This commit is contained in:
@@ -661,6 +661,8 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.clearInlineMenuFadeInTimeout();
|
||||||
|
|
||||||
await BrowserApi.tabSendMessage(
|
await BrowserApi.tabSendMessage(
|
||||||
sender.tab,
|
sender.tab,
|
||||||
{ command: "appendAutofillInlineMenuToDom", overlayElement },
|
{ command: "appendAutofillInlineMenuToDom", overlayElement },
|
||||||
@@ -673,13 +675,12 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
subFrameOffsets = subFrameOffsetsForTab.get(this.focusedFieldData.frameId);
|
subFrameOffsets = subFrameOffsetsForTab.get(this.focusedFieldData.frameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setInlineMenuFadeInTimeout();
|
|
||||||
|
|
||||||
if (overlayElement === AutofillOverlayElement.Button) {
|
if (overlayElement === AutofillOverlayElement.Button) {
|
||||||
this.inlineMenuButtonPort?.postMessage({
|
this.inlineMenuButtonPort?.postMessage({
|
||||||
command: "updateAutofillInlineMenuPosition",
|
command: "updateAutofillInlineMenuPosition",
|
||||||
styles: this.getInlineMenuButtonPosition(subFrameOffsets),
|
styles: this.getInlineMenuButtonPosition(subFrameOffsets),
|
||||||
});
|
});
|
||||||
|
this.setInlineMenuFadeInTimeout();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -688,6 +689,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
command: "updateAutofillInlineMenuPosition",
|
command: "updateAutofillInlineMenuPosition",
|
||||||
styles: this.getInlineMenuListPosition(subFrameOffsets),
|
styles: this.getInlineMenuListPosition(subFrameOffsets),
|
||||||
});
|
});
|
||||||
|
this.setInlineMenuFadeInTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -789,17 +791,11 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
* @param display - The display property of the inline menu, either "block" or "none"
|
* @param display - The display property of the inline menu, either "block" or "none"
|
||||||
* @param sender - The sender of the extension message
|
* @param sender - The sender of the extension message
|
||||||
*/
|
*/
|
||||||
private updateInlineMenuHidden(
|
private async updateInlineMenuHidden(
|
||||||
{ isInlineMenuHidden, setTransparentInlineMenu }: OverlayBackgroundExtensionMessage,
|
{ isInlineMenuHidden, setTransparentInlineMenu }: OverlayBackgroundExtensionMessage,
|
||||||
sender: chrome.runtime.MessageSender,
|
sender: chrome.runtime.MessageSender,
|
||||||
) {
|
) {
|
||||||
if (isInlineMenuHidden) {
|
this.clearInlineMenuFadeInTimeout();
|
||||||
this.clearInlineMenuFadeInTimeout();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setTransparentInlineMenu) {
|
|
||||||
this.setInlineMenuFadeInTimeout();
|
|
||||||
}
|
|
||||||
|
|
||||||
const display = isInlineMenuHidden ? "none" : "block";
|
const display = isInlineMenuHidden ? "none" : "block";
|
||||||
let styles: { display: string; opacity?: string } = { display };
|
let styles: { display: string; opacity?: string } = { display };
|
||||||
@@ -809,7 +805,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
styles = { ...styles, opacity };
|
styles = { ...styles, opacity };
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserApi.tabSendMessage(
|
await BrowserApi.tabSendMessage(
|
||||||
sender.tab,
|
sender.tab,
|
||||||
{ command: "toggleAutofillInlineMenuHidden", isInlineMenuHidden },
|
{ command: "toggleAutofillInlineMenuHidden", isInlineMenuHidden },
|
||||||
{ frameId: 0 },
|
{ frameId: 0 },
|
||||||
@@ -818,6 +814,10 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
const portMessage = { command: "toggleAutofillInlineMenuHidden", styles };
|
const portMessage = { command: "toggleAutofillInlineMenuHidden", styles };
|
||||||
this.inlineMenuButtonPort?.postMessage(portMessage);
|
this.inlineMenuButtonPort?.postMessage(portMessage);
|
||||||
this.inlineMenuListPort?.postMessage(portMessage);
|
this.inlineMenuListPort?.postMessage(portMessage);
|
||||||
|
|
||||||
|
if (setTransparentInlineMenu) {
|
||||||
|
this.setInlineMenuFadeInTimeout();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -255,6 +255,7 @@ export class AutofillInlineMenuIframeService implements AutofillInlineMenuIframe
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.clearFadeInTimeout();
|
||||||
this.updateElementStyles(this.iframe, position);
|
this.updateElementStyles(this.iframe, position);
|
||||||
this.announceAriaAlert();
|
this.announceAriaAlert();
|
||||||
}
|
}
|
||||||
@@ -308,13 +309,16 @@ export class AutofillInlineMenuIframeService implements AutofillInlineMenuIframe
|
|||||||
}
|
}
|
||||||
|
|
||||||
private handleFadeInInlineMenuIframe() {
|
private handleFadeInInlineMenuIframe() {
|
||||||
|
this.clearFadeInTimeout();
|
||||||
|
this.fadeInTimeout = globalThis.setTimeout(() => {
|
||||||
|
this.updateElementStyles(this.iframe, { display: "block", opacity: "1" });
|
||||||
|
}, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
private clearFadeInTimeout() {
|
||||||
if (this.fadeInTimeout) {
|
if (this.fadeInTimeout) {
|
||||||
clearTimeout(this.fadeInTimeout);
|
clearTimeout(this.fadeInTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fadeInTimeout = globalThis.setTimeout(() => {
|
|
||||||
this.updateElementStyles(this.iframe, { display: "block", opacity: "1" });
|
|
||||||
}, 25);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user