-
-
Notifications
You must be signed in to change notification settings - Fork 918
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
incorrect behaviour of "routing-event"s #484
Comments
@joeldenning look at it please ^^^ |
Hi! Want to add a bit more clarity here... I also checked PRs in which tracking of the At the same time I understand that such a change (modification of the And finally (and this may not be aligned with @nightnei), I'm not sure if we need to alter any logic that is related to |
This is how https://github.com/mapbox/scroll-restorer uses https://github.com/mapbox/scroll-restorer/blob/1d187db54cefec24e5618fd8a595392a6de742cf/index.js#L62 So it only extends |
Ah interesting. Did you find this because performance became bad as you scrolled? In any case, I agree with your assessment - single-spa probably shouldn't be calling that if the url itself hasn't changed. Like @StyleT mentioned, to avoid a breaking change we could provide it as an option (defaulted off), and then on next major release we could default that option to on (but still provide it as an option?) |
Some backgroundWithin single-spa, calling pushState/replaceState does two things:
Regarding 1 - It is possible (although not common) for activity functions to check Regarding 2 - It is also possible (altough not very common) for other microfrontends on the page to check Regarding the popstate eventsingle-spa intentionally deviates from the browser's default behavior when it comes to A questionDoes the above behavior cause an error within scroll-restorer? Or is the problem the performance cost of 1 and 2 occurring for every pixel scrolled? |
If our goal is to improve performance, what do you think of the following options for an API? singleSpa.start({
urlRerouteOnly: true
}) singleSpa.setUrlRerouteOnly(true) ^ Is this similar to what you are thinking for an API to control this? I think we'd start it off as opt-in and then make it the default in single-spa@6 (whenever that happens) |
@joeldenning agree with everything you said in "Some background" & "Regarding the popstate event" sections. We see some minor performance issues indeed. And it's generally unexpected a little bit :) I'm fully for the |
Added this in #487 |
Documented in single-spa/single-spa.js.org#204 |
@joeldenning you rock! thank you :) |
history.pushstate
andhistory.replacestate
have 3 parameters. and the third parameter is URL, which is optional.https://html.spec.whatwg.org/multipage/history.html#dom-history-pushstate
so even if we use
window.history.pushState({}, '')
- eventssingle-spa:before-routing-event
andsingle-spa:routing-event
will be fired and methodisActive
of every registered app will be run;our case: we use https://github.com/mapbox/scroll-restorer in our service https://github.com/namecheap/ilc. and scroll-restorer saves scroll position in the state of history. it's important if we use back/forward buttons in a browser. so every time when a user just scrolls page - it uses pushstate and in result - single-spa think that route is changed.
https://github.com/single-spa/single-spa/blob/108292928d225e1fd7c80245f2d6d6128edd4ee5/src/navigation/navigation-events.js#L124`
The text was updated successfully, but these errors were encountered: