-
Notifications
You must be signed in to change notification settings - Fork 546
propsal for exact active behavior customization in router-link #35
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
Conversation
What if instead the |
it could be an extra option, indeed, but I wonder if it's necessary since it could also be done through the scoped slot (although it depends on what arguments you want to pass to the function): const isExact = (current, location) => location.path === current.path <router-link v-slot="{ location }">
<a :class="matchLocation($route, location) && 'is-active'">Link</a>
</router-link> |
Yeah I think it should all be achievable with the slot API, and we should make sure it's easy to match several parts of the location. Then we could remove the <router-link v-slot="{ location, navigate, exact }">
<a
:href="location"
:class="{ 'router-link-active-exact': exact.path && exact.query }"
@click="navigate"
>
Link
</a>
</router-link> |
I feel this new |
I agree it can all be achieved through the scoped slot haha but it does make it much easier to use, so I don't think we should remove it altogether hehe. The most common use would be |
So instead of having a new way of using <router-link to="/" exact-path>Home</router-link> |
In the end, I think it would be less confusing and easier to learn that having different ways of using |
yes, we could but because it's either using |
Maybe we could just remove the |
So instead of having an <router-link class="exact" to="/">Home</router-link>
<router-link to="/foobar">Foobar</router-link> :not(.exact).router-link-active,
.exact.router-link-active-exact {
background: green;
} |
About the table It's funny, I felt the same way when I wrote it, but it should be treated as examples not as a table that would be included in the documentation. I realized it doesn't feel that complicated if I ignore the table and read it as a sentence that says we can match some specific parts of a location only and match multiple ones with a
that's another alternative I forgot to add but it's more complicating and also adds even more props to the router-link (active-link-class companions). Also, if we have one for path, why not query and hash? That's what people could ask for and that would create even more props |
Then they can just use the slot API. I really feel this is all overkill, and that the |
In the end I think we should just leave the |
Another possible change: remove |
It's a possibility but there is a real need for matching the path only without the query and the hash. Since using a scoped slot will always be a lot more work than using the regular slot api, I think we should allow at least :not(.exact).router-link-active,
.exact.router-link-active-exact {
background: green;
} I didn't think about this one! It's a good one. I still want framework/library users to be able to provide a single class for |
I just though about an issue with the proposal: what if you want to have styling for let's say |
Do you mean all of the them at the same time, different styling? the way I was thinking about the exact prop is:
|
Yes |
Closing in favor of a much more simple RFC https://github.com/vuejs/rfcs/pull/37/files |
Rendered