Skip to content

Commit

Permalink
Fix navigateToApp behavior when openInNewTab is true (elastic#110712)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykkopycinski authored and kibanamachine committed Sep 23, 2021
1 parent 2327100 commit f247bc7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
15 changes: 15 additions & 0 deletions src/core/public/application/application_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
9 changes: 4 additions & 5 deletions src/core/public/application/application_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand Down

0 comments on commit f247bc7

Please sign in to comment.