Closed tragid closed 2 months ago
The param can be parsed in different ways so it can end up as either undefined
or ''
(empty string). In the end I decided to not normalize the value since both are usually check with if (!route.param.id)
.
In the future this will likely be overruled by a way to parse params like https://github.com/posva/unplugin-vue-router/discussions/303
Reproduction
https://github.com/tragid/vue-router-popstate-bug
Steps to reproduce the bug
router.push({ name: 'debug' })
route.params.paramId
isundefined
.router.push({ name: 'debug', params: { paramId: '123' } })
route.params.paramId
is'123'
.route.params.paramId
is empty string instead ofundefined
.Expected behavior
Optional parameter should by of one type rather undefined or empty string, when pushing to it or going back with browsers navigation.
Actual behavior
Optional parameter is undefined when is direct router.push, and empty string when going back with browser's navigation. If having some watcher on this parameter, it has false positive triggering.
Uploading Screen Recording 2024-04-16 at 12.18.58.mov…
Additional information
No response