Fix navigateToApp behavior when openInNewTab is true (#110712)

This commit is contained in:
Patryk Kopyciński 2021-09-23 16:48:16 +02:00 committed by GitHub
parent 467e5851a3
commit 854e0d4d85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 5 deletions

View file

@ -804,6 +804,21 @@ describe('#start()', () => {
`);
});
it("when openInNewTab is true it doesn't update currentApp$ after mounting", async () => {
service.setup(setupDeps);
const { currentAppId$, navigateToApp } = await service.start(startDeps);
const stop$ = new Subject();
const promise = currentAppId$.pipe(bufferCount(4), takeUntil(stop$)).toPromise();
await navigateToApp('delta', { openInNewTab: true });
stop$.next();
const appIds = await promise;
expect(appIds).toBeUndefined();
});
it('updates httpLoadingCount$ while mounting', async () => {
// Use a memory history so that mounting the component will work
const { createMemoryHistory } = jest.requireActual('history');

View file

@ -250,16 +250,15 @@ export class ApplicationService {
if (path === undefined) {
path = applications$.value.get(appId)?.defaultPath;
}
if (!navigatingToSameApp) {
this.appInternalStates.delete(this.currentAppId$.value!);
}
if (openInNewTab) {
this.openInNewTab!(getAppUrl(availableMounters, appId, path));
} else {
if (!navigatingToSameApp) {
this.appInternalStates.delete(this.currentAppId$.value!);
}
this.navigate!(getAppUrl(availableMounters, appId, path), state, replace);
this.currentAppId$.next(appId);
}
this.currentAppId$.next(appId);
}
};