DEV Community

Discussion on: Handling Dialogs with Vue Router

 
berniwittmann profile image
Bernhard Wittmann

The thing is you don't have to worry about destroying the underlying gallery since the gallery does not depend on the route itself anymore (only indirectly).

I just adjusted the example code to showcase that this can indeed work. Just see this branch: github.com/BerniWittmann/vue-route...

You can navigate to localhost:8080/nested/one?foo=test which resembles the gallery and see the query parameters rendered (because they have been stored in the state in the beforeEnter route guard). When you click on the show dialog button the url changes to /dialog which resembles the work page. You will see, that the page below did not change. It still has the query parameters rendered and also it was not even rerendered at all, which you can see at the timestamp.
As you'll see the back/close button will also work as expected and you can easily specify a default behavior when the local storage is empty on the work page. Hope that helps ;)

Thread Thread
 
stepanorda profile image
Stepan

Thank you, now I get your idea :) Really appreciate your going to such a length trying to help me!

Thread Thread
 
berniwittmann profile image
Bernhard Wittmann

No worries, Iā€˜m glad to help :)

Thread Thread
 
stepanorda profile image
Stepan

For everybody who would like me google and find your article first:
github.com/vuejs/vue-router/issues...
This is a known issue, there are future request in and it's planned to be addressed by vue-router.
There are also a lot of hacky solutions for this in that issue.