There are numerous issue related to the way the URLs are generated (and therefore): #1366 #1543 #1799 #2172 #1089
Overall what we can see is that the lack of control is frustrating and the API was never meant to be that flexible: it's a quick fix so that anyone can have a URL in sync no matter what. However we can think of ways to improve those.
One that could be done is that we could provide a function for the rendering of the URL based on the search state. It would be up to this function to encode the state into a URL or a part of the URL. Also this would require to implement the decoder too.
{
urlSync: {
encode: function(state) { return `${window.location.origin}${window.location.pathname}?q=${state.getQuery()}` }
},
decode: function(url, state) { return state.setQuery(readURLStringForQuery(url)); },
}
Another thing that is noted is that the UI state cannot be synchronised. What if the widget were able to provide their current state via a new method on the widget interface: getURLState. This object would return an object that would be aggregated over all the instanciated widgets.
A lot of thoughts to go through here. Let's keep this issue as the central point to think about URL sync and its future.
Edit 1: Started a PoC with a more complete solution.
Any progress on this question?
I've got a second customer who needs this :)
I think encode/decode is acceptable, although not as friendly as what I had proposed in #2172 – but it would be enough to start with and can be implemented independently from the second issue you're raising regarding the widget states.
No progress for the moment. I was actually waiting for some reactions, so that's good that you've raised your voice 👍
Work on this has started. I implemented a more complete solution. Everything is explained in the PoC pull request.
This is released in 2.7.x cc @olance
Most helpful comment
Work on this has started. I implemented a more complete solution. Everything is explained in the PoC pull request.