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

[PM-5189] Fixing an issue found when switching between open windows

This commit is contained in:
Cesar Gonzalez 2024-06-25 12:23:53 -05:00
parent b9c18b5526
commit a44f594e6d
No known key found for this signature in database
GPG Key ID: 3381A5457F8CCECF
2 changed files with 17 additions and 8 deletions

View File

@ -163,7 +163,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
private initOverlayEventObservables() { private initOverlayEventObservables() {
this.repositionInlineMenuSubject this.repositionInlineMenuSubject
.pipe( .pipe(
debounceTime(950), debounceTime(1000),
switchMap((sender) => this.repositionInlineMenu(sender)), switchMap((sender) => this.repositionInlineMenu(sender)),
) )
.subscribe(); .subscribe();
@ -176,7 +176,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
// Debounce used to update inline menu position // Debounce used to update inline menu position
merge( merge(
this.startUpdateInlineMenuPositionSubject.pipe(debounceTime(250)), this.startUpdateInlineMenuPositionSubject.pipe(debounceTime(150)),
this.cancelUpdateInlineMenuPositionSubject, this.cancelUpdateInlineMenuPositionSubject,
) )
.pipe(switchMap((sender) => this.updateInlineMenuPositionAfterRepositionEvent(sender))) .pipe(switchMap((sender) => this.updateInlineMenuPositionAfterRepositionEvent(sender)))
@ -216,6 +216,9 @@ export class OverlayBackground implements OverlayBackgroundInterface {
async updateInlineMenuCiphers() { async updateInlineMenuCiphers() {
const authStatus = await firstValueFrom(this.authService.activeAccountStatus$); const authStatus = await firstValueFrom(this.authService.activeAccountStatus$);
if (authStatus !== AuthenticationStatus.Unlocked) { if (authStatus !== AuthenticationStatus.Unlocked) {
if (this.focusedFieldData) {
void this.closeInlineMenuAfterCiphersUpdate();
}
return; return;
} }
@ -224,6 +227,10 @@ export class OverlayBackground implements OverlayBackgroundInterface {
return; return;
} }
if (this.focusedFieldData && currentTab.id !== this.focusedFieldData.tabId) {
void this.closeInlineMenuAfterCiphersUpdate();
}
this.inlineMenuCiphers = new Map(); this.inlineMenuCiphers = new Map();
const ciphersViews = (await this.cipherService.getAllDecryptedForUrl(currentTab.url)).sort( const ciphersViews = (await this.cipherService.getAllDecryptedForUrl(currentTab.url)).sort(
(a, b) => this.cipherService.sortCiphersByLastUsedThenName(a, b), (a, b) => this.cipherService.sortCiphersByLastUsedThenName(a, b),
@ -266,6 +273,11 @@ export class OverlayBackground implements OverlayBackgroundInterface {
return inlineMenuCipherData; return inlineMenuCipherData;
} }
private async closeInlineMenuAfterCiphersUpdate() {
const focusedFieldTab = await BrowserApi.getTab(this.focusedFieldData.tabId);
this.closeInlineMenu({ tab: focusedFieldTab }, { forceCloseInlineMenu: true });
}
/** /**
* Handles aggregation of page details for a tab. Stores the page details * Handles aggregation of page details for a tab. Stores the page details
* in association with the tabId of the tab that sent the message. * in association with the tabId of the tab that sent the message.

View File

@ -94,7 +94,7 @@ export default class TabsBackground {
return; return;
} }
await this.overlayBackground.updateInlineMenuCiphers(); this.overlayBackground.updateInlineMenuCiphers();
if (this.main.onUpdatedRan) { if (this.main.onUpdatedRan) {
return; return;
@ -121,10 +121,7 @@ export default class TabsBackground {
* for the current tab. Also updates the overlay ciphers. * for the current tab. Also updates the overlay ciphers.
*/ */
private updateCurrentTabData = async () => { private updateCurrentTabData = async () => {
await Promise.all([ this.overlayBackground.updateInlineMenuCiphers();
this.main.refreshBadge(), await Promise.all([this.main.refreshBadge(), this.main.refreshMenu()]);
this.main.refreshMenu(),
this.overlayBackground.updateInlineMenuCiphers(),
]);
}; };
} }