-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Possible bugs due to different instances of history in NP apps #53692
Comments
Pinging @elastic/kibana-platform (Team:Platform) |
Pinging @elastic/kibana-app-arch (Team:AppArch) |
One possible option, similar to (1), would be for Core to expose a Here's the API surface for export interface History<HistoryLocationState = LocationState> {
length: number;
action: Action;
location: Location<HistoryLocationState>;
push(path: Path, state?: HistoryLocationState): void;
push(location: LocationDescriptorObject<HistoryLocationState>): void;
replace(path: Path, state?: HistoryLocationState): void;
replace(location: LocationDescriptorObject<HistoryLocationState>): void;
go(n: number): void;
goBack(): void;
goForward(): void;
block(
prompt?: boolean | string | TransitionPromptHook<HistoryLocationState>,
): UnregisterCallback;
listen(listener: LocationListener<HistoryLocationState>): UnregisterCallback;
createHref(location: LocationDescriptorObject<HistoryLocationState>): Href;
} On first glance, it appears only these methods would need to be wrapped to handle basePath issues:
We would also want to consider wrapping This seems like a feasible option that doesn't have any drawbacks (other than implementing/maintaining this). @Dosant thoughts? |
Seems good to me, if this history have to be used only for navigating within an app, right? Looking at my thoughts in the original description, I am now questioning if having this necessity for apps to "not forget" about base path is actually that bad. Just thinking: Also I see, that in next version of 'history', there will be a convenient singleton to use: https://github.com/ReactTraining/history/releases/tag/v5.0.0-beta.2
|
We do, there is a
Since Core dictates the appBasePath, I really would like applications to not have to worry about this at all. That way we can easily change the schema we use for applications paths in the future and we don't have to have basePath code littered throughout the code base. I'm also not sure it's a good idea for applications to have access to the full navigation history. It seems that an app should only be able to see the history stack that has happened while that app has been mounted. I worry about tight coupling that could occur through the history if the full history stack is exposed. |
Can't core just provide a wrapped |
I believe that would actually be more work because |
Summary
While digging into new state management utils #53582 I bumped into following issue in an example np app I created. The app uses react-router.
The bug is: App's react-router doesn't trigger re-render when clicking on current app link in chrome's side nav.
Reproduction
Video: https://drive.google.com/open?id=17zj0hPR96lAeRn_ehJEMFK3kh-LkbFkP
To run the same and to see code it's: #53582
Cause
It looks like it happening, because np app navigation is happening using core's instance of
history
https://github.com/elastic/kibana/blob/master/src/core/public/chrome/ui/header/header.tsx#L325, and app react-router'shistory
instance is different one, so listen cb doesn't fire for events fired by core'shistory
and react-router can't trigger rerender.Possible solution
This will cause complications with base path... as it is different for core and apps. Apps will have to append {appBasePath} to react-router configs ... so this is likely not an option
if(appIsActive){ ... }
branch here: https://github.com/elastic/kibana/blob/master/src/core/public/chrome/ui/header/header.tsx#L325and notify current app that user clicked on it's link and let app handle it?Or, just reload the page.
?
The text was updated successfully, but these errors were encountered: