Skip to content

Active class not always applied correctly when having subroutes #1014

Closed
@denjaland

Description

@denjaland

When having subroutes, and applying an active class, it goes wrong when there are replacement variables.

Especially in a case where you navigate to .../:id/... it goes wrong; the route will be shown active using a startsWith() because we can not apply 'exact' because of the subrouting.

I think the parent should only be shown active is the part BEFORE the last SLASH in the route matches exactly in stead of working with .startsWith().

Vue.js / vue-router versions

2.1.6 / 2.1.1

Reproduction Link

https://jsfiddle.net/dwa0kde5/2/

Steps to reproduce

Click the links on the fiddle; the active class shows a red border to the links; you'll soon see where it goes wrong :-)

What is Expected?

When vieweing id 10 / 100 / 1XXX, the /1 route should NOT be active. I believe the slashes should be determining where the parent route ends.

What is actually happening?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions