-
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
[Discuss] Browser location management in NP #58217
Comments
Pinging @elastic/kibana-platform (Team:Platform) |
Pinging @elastic/kibana-app-arch (Team:AppArch) |
I don't think we have to add a global event handler in order to still maintain our framework-agnostic goals of Core. We could recommend using That said, I'm not necessarily against a global event handler if it greatly simplifies this for plugins (which I suspect it might). I think it's something worth exploring and making sure there aren't any edge cases that could be hard to handle.
I do not really like this option. I think much of the confusion in our legacy URL management came from global mechanisms changing the routing behaviors for all applications. However, if just What is the exact use case here that the opt-in approach outlined in #39855 does not work for?
I think this makes sense to possibly bake into |
I've split this issue into 3 separate issues so each can be prioritized accordingly by the platform team. |
Browser location management in NP
Working on state syncing utils and
AppState
/GlobalState
replacement #44151 made me thinking that NP is probably missing some primitives (or documented guidance) for working with browser location.I think we didn't bump into many blocking issues so far because of the transitional
period where most apps are using angular, hashed routing and navigation between them could happen with full browser page reload.
But as we start to see more apps cut-off in new platform, some issues started to come up #58112, #53692
I tried to outline some other possible issues which would likely become important on some point.
Especially as more apps are migrated to NP, stop using angular and hashed routing. And when kibana is a compete single page application.
Assuming platform is still handling mounting and unmounting apps using
react-router
andhistory
I can think of following problems:Deep linking between NP apps
Problem
Core provides an imperative api for navigation between apps.
But apps and plugins would also create regular
html
links to other places in kibanaWith current NP setup clicking on such link would likely not properly work,
because platform's
react-router
won't be notified about this location change.To make this link work properly it have to be rendered with
react-router
's<Link/>
. App's<Router/>
instance have to use
ScopedHistory
provided by core.But if all the code that renders links have to use
<Link/>
it means it have to also useReact
which is not framework-agnostic.Why this wasn't a problem before?
There is a
window
eventhashchange
. But it doesn't work for not hash urls. So this becomes a problem when we move to single page app setup with urls without#
.Possible solution
<Link/>
wrapped in core'sScopedHistory
instance is crucial. (not likely as it enforces to use react any rendering)a[href]
clicks and notifies it'sreact-router
about navigation between apps. Something similar to this but for all links.Listening for url changes
Problem
Before NP, apps or plugins could listen for url change using angular's
$location
orhashchange
event.In NP
ScopedHistory.listen
should be sufficient for apps (assuming all the url updates are happening using correcthistory
instance).But we recently bumped into the case, where we wanted to explore managing part of the url from the
data
plugin. cc @lizozom @timroes (even though this idea diverges from #39855)We thought of making plugin subscribe for url changes in the setup phase. Plugin would also have to be able to do query updates.
Possible solution
history
instance? Or expose justlisten
callback and a centralised way to update query params so all listeners would be properly notified?Batching url updates
Problem
In NP we don't have a mechanism to batch multiple url changes into one browser history stack update.
Before NP we could use
$location
. It batched all url changes and applied them in next digest cycle.To replace
AppState
andGlobalState
which relied on this$location
's behaviour, we implemented query updates batching insidestate_sync
utils. more.But only
state_sync
benefits from this right now.The usage ergonomics of these utils is also not good, as developers should always use the same
history
/kbnUrlStateStorage
for correct simultaneous state syncing of different sources with url. Because of this we can't setup state syncing with url from two different places askbnUrlStateStorage
, which does the batching, is not available globally. As an example: we want separately setup syncing of data plugin state with_g
query param + and application state with_a
query param)Solution
history
) which would allow to batch url updates.AppState
/GlobalState
replacement use casekbnUrlStateStorage
solves this, We could continue to implement local solutions for this.Scroll restoration
@Dosant: todo, investigate if this is a problem and what is the impact.
The text was updated successfully, but these errors were encountered: