Closed
Description
What problem does this feature solve?
Since a recent change every call to push
or replace
that is handed the same path as is currently active is rejecting with a NavigationDuplicated
error and clients that don't care about this duplication need to attach a no-op catch
clause to all calls. I am aware that there was already a discussion on this topic in #2872 and can understand the viewpoints expressed by the maintainers there. However I'd still like to ask to reconsider this change and not reject for duplicated navigations.
The main arguments I would put into consideration against treating NavigationDuplicated
as an error are:
- Not rejecting is more consistent with how
<a>
tags and<router-link>
are working, i. e. I'd argue it is the API that is least surprising to users ofvue-router
because it is how browsers usually work. - A client can already find out if a duplication is happening by looking at the current route and the push target if this functionality is desired. While this might be slightly more complicated for that use-case, the changed API puts a burden on all clients that don't care about the duplication, which is IMHO the more common case.
- It essentially seems not possible anymore to call
push
without an attachedcatch
because otherwise we might get irrelevant error logs, i. e. the API is now always (albeit minimally) more complex. - Introducing the rejection was effectively a breaking change of the API for a lot of clients. The observable behaviour of pushing the same navigation twice was a no-op before and now it isn't anymore.
What does the proposed API look like?
A duplicated navigation is a "no-op" or warning log in vue-router itself and doesn't require clients to handle this in any way.
Metadata
Metadata
Assignees
Labels
No labels
Activity