1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-25 21:51:30 +01:00

[PM-5189] Fixing issues found within code review behind how we position elements

This commit is contained in:
Cesar Gonzalez 2024-06-24 19:08:02 -05:00
parent 6112d989ce
commit 45c1f78485
No known key found for this signature in database
GPG Key ID: 3381A5457F8CCECF
2 changed files with 10 additions and 6 deletions

View File

@ -173,6 +173,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
) )
.subscribe(); .subscribe();
// Debounce used to update inline menu position
merge( merge(
this.startUpdateInlineMenuPositionSubject.pipe(debounceTime(150)), this.startUpdateInlineMenuPositionSubject.pipe(debounceTime(150)),
this.cancelUpdateInlineMenuPositionSubject, this.cancelUpdateInlineMenuPositionSubject,
@ -793,8 +794,11 @@ export class OverlayBackground implements OverlayBackgroundInterface {
{ isInlineMenuHidden, setTransparentInlineMenu }: ToggleInlineMenuHiddenMessage, { isInlineMenuHidden, setTransparentInlineMenu }: ToggleInlineMenuHiddenMessage,
sender: chrome.runtime.MessageSender, sender: chrome.runtime.MessageSender,
) { ) {
this.cancelInlineMenuFadeIn(); if (sender.tab.id !== this.focusedFieldData?.tabId) {
return;
}
this.cancelInlineMenuFadeIn();
const display = isInlineMenuHidden ? "none" : "block"; const display = isInlineMenuHidden ? "none" : "block";
let styles: { display: string; opacity?: string } = { display }; let styles: { display: string; opacity?: string } = { display };
@ -1199,6 +1203,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
*/ */
private async triggerSubFrameFocusInRebuild(sender: chrome.runtime.MessageSender) { private async triggerSubFrameFocusInRebuild(sender: chrome.runtime.MessageSender) {
this.rebuildSubFrameOffsetsSubject.next(sender); this.rebuildSubFrameOffsetsSubject.next(sender);
this.cancelUpdateInlineMenuPositionSubject.next();
this.repositionInlineMenuSubject.next(sender); this.repositionInlineMenuSubject.next(sender);
} }
@ -1209,7 +1214,6 @@ export class OverlayBackground implements OverlayBackgroundInterface {
* @param sender - The sender of the message * @param sender - The sender of the message
*/ */
private repositionInlineMenu = async (sender: chrome.runtime.MessageSender) => { private repositionInlineMenu = async (sender: chrome.runtime.MessageSender) => {
this.cancelUpdateInlineMenuPositionSubject.next();
if (!this.isFieldCurrentlyFocused) { if (!this.isFieldCurrentlyFocused) {
await this.closeInlineMenuAfterReposition(sender); await this.closeInlineMenuAfterReposition(sender);
return; return;
@ -1229,7 +1233,6 @@ export class OverlayBackground implements OverlayBackgroundInterface {
this.rebuildSubFrameOffsetsSubject.next(sender); this.rebuildSubFrameOffsetsSubject.next(sender);
} }
this.cancelUpdateInlineMenuPositionSubject.next();
this.startUpdateInlineMenuPositionSubject.next(sender); this.startUpdateInlineMenuPositionSubject.next(sender);
}; };

View File

@ -313,9 +313,10 @@ export class AutofillInlineMenuIframeService implements AutofillInlineMenuIframe
*/ */
private handleFadeInInlineMenuIframe() { private handleFadeInInlineMenuIframe() {
this.clearFadeInTimeout(); this.clearFadeInTimeout();
this.fadeInTimeout = globalThis.setTimeout(() => { this.fadeInTimeout = globalThis.setTimeout(
this.updateElementStyles(this.iframe, { display: "block", opacity: "1" }); () => this.updateElementStyles(this.iframe, { display: "block", opacity: "1" }),
}, 10); 10,
);
} }
/** /**