Skip to content

feat(b-link): support exact-path and exact-path-active-class props for router link (fixes #6434) #6811

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

Merged
merged 3 commits into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/common-props.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
"exactActiveClass": {
"description": "<router-link> prop: Configure the active CSS class applied when the link is active with exact match. Typically you will want to set this to class name 'active'"
},
"exactPath": {
"description": "<router-link> prop: Allows matching only using the path section of the url, effectively ignoring the query and the hash sections"
},
"exactPathActiveClass": {
"description": "<router-link> prop: Configure the active CSS class applied when the link is active with exact path match. Typically you will want to set this to class name 'active'"
},
"fade": {
"description": "When set to `true`, enables the fade animation/transition on the component"
},
Expand Down
28 changes: 28 additions & 0 deletions docs/markdown/reference/router-links/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,34 @@ With components that support router links (have a `to` prop), you will want to s
`'active'` (or a space separated string that includes `'active'`) to apply Bootstrap's active
styling on the component when the current route matches the `to` prop.

### `exact-path`

- type: `boolean`
- default: `false`
- availability: Vue Router 3.5.0+

Allows matching only using the `path` section of the url, effectively ignoring the `query` and the
`hash` sections.

```html
<!-- this link will also be active at `/search?page=2` or `/search#filters` -->
<router-link to="/search" exact-path> </router-link>
```

### `exact-path-active-class`

- type: `string`
- default: `'router-link-exact-path-active'`
- availability: Vue Router 3.5.0+

Configure the active CSS class applied when the link is active with exact path match. Note the
default value can also be configured globally via the `linkExactPathActiveClass` router constructor
option.

With components that support router links (have a `to` prop), you will want to set this to the class
`'active'` (or a space separated string that includes `'active'`) to apply Bootstrap's active
styling on the component when the current route matches the `to` prop.

## Nuxt.js specific router link props

When BootstrapVue detects that your app is running under [Nuxt.js](https://nuxtjs.org), it will
Expand Down
2 changes: 2 additions & 0 deletions src/components/link/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export const routerLinkProps = {
event: makeProp(PROP_TYPE_ARRAY_STRING),
exact: makeProp(PROP_TYPE_BOOLEAN, false),
exactActiveClass: makeProp(PROP_TYPE_STRING),
exactPath: makeProp(PROP_TYPE_BOOLEAN, false),
exactPathActiveClass: makeProp(PROP_TYPE_STRING),
replace: makeProp(PROP_TYPE_BOOLEAN, false),
routerTag: makeProp(PROP_TYPE_STRING),
to: makeProp(PROP_TYPE_OBJECT_STRING)
Expand Down