Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

link active class not being applied to parent route #2785

Closed
autumnwoodberry opened this issue May 28, 2019 · 1 comment
Closed

link active class not being applied to parent route #2785

autumnwoodberry opened this issue May 28, 2019 · 1 comment

Comments

@autumnwoodberry
Copy link

Version

3.0.2

Reproduction link

https://codepen.io/autumnwoodberry/pen/jovEqW?editors=1010

Steps to reproduce

Use vue-router version 3.0.6. Create a parent route with 2 child routes:

/parent
/parent/child-1
/parent/child-2

Add a redirect function to the parent route that will automatically redirect to child-1.
Create a router link for all 3 routes.
Observe that when the URL is /parent/child-1 the router link to /parent has the active route css class.
Observe that when the URL is /parent/child-2 the router link to /parent does NOT have the active route css class.

In version 3.0.2 the route active class will still be on the /parent router link when the URL is /parent/child-2.

Here is the working version example: https://codepen.io/autumnwoodberry/pen/jovEqW?editors=1010
And here is the non-working version example: https://codepen.io/autumnwoodberry/pen/yWxyYJ

What is expected?

Route active class should be present on a link to a parent route when the child route is active.

What is actually happening?

The route active class is not present.

@posva
Copy link
Member

posva commented May 29, 2019

A redirect with a component doesn't make sense, you should use an empty child with a redirect instead but then you will find this issue: #2724
I'm closing this as a duplicate of that

@posva posva closed this as completed May 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants