Skip to content
Advertisement

framework7: broken tab links after stripping worker IDs from URL

shinyMobile’s inst/framework7-5.7.8/my-app.js file has the following code chunk at the top:

if (typeof workerId != "undefined") {
  var hash = window.location.hash;
  var search = window.location.search;
  var pathname = window.location.pathname;
  var newpath = pathname + workerId + search + hash;
  window.history.replaceState( {} , 'newpath', newpath);
}

It appends a random string (the worker ID) to the URL of the app whenever it is not run locally. E.g., https://my_domain/my_app/ becomes https://my_domain/my_app/_w_123456/.

This is super annoying, as it prevents search parameters (e.g., ?param=test) from being consistently captured (screencast video).

So, I followed the solution found in this post and commented out the line window.history.replaceState( {} , 'newpath', newpath); above.

Now, worker IDs do not appear in the URL anymore. But the links of the app’s tabs are still somehow initialized with the worker IDs! E.g., https://my_domain/my_app/_w_123456/#tabset-tab1. And, upon first click, because of my change above, they get updated to not containing the worker IDs (https://my_domain/my_app/#tabset-tab1), causing them to become broken! Please see this new screencast.

I tried to locate the script where the tab links are initialized in shinyMobile, but I could not find it. Maybe it is a framework7 feature?

Any tip would be greatly appreciated, as I have absolutely no clue how to solve this.

PS: I did post to shinyMobile’s GitHub, but looking at the other recent issues, it seems it is unlikely I will get an answer any time soon.

Advertisement

Answer

The author of the package implemented a fix: https://github.com/RinteRface/shinyMobile/issues/140#issuecomment-754765964 Many thanks to him!

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement