🌐 AI搜索 & 代理 主页
Skip to content

Commit a5aca94

Browse files
committed
Merge branch 'fix-nav-item-dropdown-href' of https://github.com/bootstrap-vue/bootstrap-vue into fix-nav-item-dropdown-href
2 parents 98565c4 + f4dff9e commit a5aca94

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
"@nuxtjs/google-analytics": "^2.2.3",
107107
"@nuxtjs/pwa": "^3.0.0-beta.20",
108108
"@nuxtjs/robots": "^2.4.2",
109-
"@nuxtjs/sitemap": "^2.2.1",
109+
"@nuxtjs/sitemap": "^2.3.0",
110110
"@testing-library/jest-dom": "^5.7.0",
111111
"@vue/test-utils": "^1.0.2",
112112
"autoprefixer": "^9.7.6",

src/components/nav/README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,13 @@ Use `<b-nav-item-dropdown>` to place dropdown items within your nav.
190190

191191
Sometimes you want to add your own class names to the generated dropdown toggle button, that by
192192
default have the classes `nav-link` and `dropdown-toggle`. Use the `toggle-class` prop to add them
193-
(like above) which will produce something like:
193+
(like above) which will render HTML similar to:
194194

195195
```html
196196
<li id="my-nav-dropdown" class="nav-item b-nav-dropdown dropdown">
197197
<a
198-
href="#"
198+
role="button"
199+
href="#my-nav-dropdown"
199200
id="my-nav-dropdown__BV_button_"
200201
aria-haspopup="true"
201202
aria-expanded="false"
@@ -222,6 +223,17 @@ shown. When there are a large number of dropdowns rendered on the same page, per
222223
impacted due to larger overall memory utilization. You can instruct `<b-nav-item-dropdown>` to
223224
render the menu contents only when it is shown by setting the `lazy` prop to true.
224225

226+
### Dropdown implementation note
227+
228+
Note that the toggle button is actually rendered as a link `<a>` tag with `role="button"` for
229+
styling purposes, and typically has the `href` set to `#` unless and ID is provided via the `id`
230+
prop.
231+
232+
The toggle will prevent scroll top top behaviour (via javascript) when clicking the toggle link. In
233+
some cases when using SSR, and the user clicks the toggle button _before_ Vue has had a chance to
234+
hydrate the component, the page will scroll to top. In these cases, simply providing a unique ID
235+
via the `id` prop will prevent the unwanted scroll to top behaviour.
236+
225237
## Nav text content
226238

227239
Use the `<b-nav-text>` child component to place plain text content into the nav:

src/components/nav/nav-item-dropdown.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ describe('nav-item-dropdown', () => {
8787
await waitNT(wrapper.vm)
8888

8989
expect(wrapper.element.hasAttribute('id')).toBe(true)
90+
expect(wrapper.attributes('id').toEqual('foo')
9091

9192
const $toggle = wrapper.find('.dropdown-toggle')
92-
expect($toggle.attributes('href')).toEqual(`#${wrapper.attributes('id')}`)
93+
expect($toggle.attributes('href')).toEqual('#foo')
9394

9495
wrapper.destroy()
9596
})

yarn.lock

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,13 +1594,13 @@
15941594
resolved "https://registry.yarnpkg.com/@nuxtjs/robots/-/robots-2.4.2.tgz#9a96c91abb70e39b414eec502ef1cf7d5ef0235e"
15951595
integrity sha512-BW3qhvxlPBKlMkZHtARFPeliFraiZHS28G3j4qgRbSfOBtHC0yDX3Dnq1LkQMzAbPfbw6A1L3sdjgBVZZnfFAw==
15961596

1597-
"@nuxtjs/sitemap@^2.2.1":
1598-
version "2.2.1"
1599-
resolved "https://registry.yarnpkg.com/@nuxtjs/sitemap/-/sitemap-2.2.1.tgz#a00b528e361673b3f2651a0f1ee4081e89f9c6fd"
1600-
integrity sha512-GrXTueBaSQgAuBbUrGcKu37VbZBOZ4omHqk8FfthK71R26vp9LWUcqlRbuQaIrAYynjSfSPxaLpX8opUwO1nKw==
1597+
"@nuxtjs/sitemap@^2.3.0":
1598+
version "2.3.0"
1599+
resolved "https://registry.yarnpkg.com/@nuxtjs/sitemap/-/sitemap-2.3.0.tgz#ca032b84f54a6570123305098b2b9a7821f4ab29"
1600+
integrity sha512-mSh0vc8HuJHMOm8ifKIKXxGETDq+Oc7MgwWVeq20AEfblNQUOWFLv+bYqh8BkxvuXc2/488zMrKhWOfwzasQOA==
16011601
dependencies:
16021602
async-cache "^1.1.0"
1603-
consola "^2.11.3"
1603+
consola "^2.12.1"
16041604
etag "^1.8.1"
16051605
fresh "^0.5.2"
16061606
fs-extra "^8.1.0"
@@ -3811,6 +3811,11 @@ consola@^2.10.0, consola@^2.10.1, consola@^2.11.3, consola@^2.6.0, consola@^2.9.
38113811
resolved "https://registry.yarnpkg.com/consola/-/consola-2.11.3.tgz#f7315836224c143ac5094b47fd4c816c2cd1560e"
38123812
integrity sha512-aoW0YIIAmeftGR8GSpw6CGQluNdkWMWh3yEFjH/hmynTYnMtibXszii3lxCXmk8YxJtI3FAK5aTiquA5VH68Gw==
38133813

3814+
consola@^2.12.1:
3815+
version "2.12.1"
3816+
resolved "https://registry.yarnpkg.com/consola/-/consola-2.12.1.tgz#88e9311a02cb88a7f6f9488239dd30b6ba99cbb0"
3817+
integrity sha512-aEkkju9ZcEa9y2MhzNhfmTUws/CEZZ0LKu0FxftSU3HygPfVMMIMSYyYct+xBN6XNRhsaDZjw2HAv3m2ammXSA==
3818+
38143819
console-browserify@^1.1.0:
38153820
version "1.2.0"
38163821
resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.2.0.tgz#67063cef57ceb6cf4993a2ab3a55840ae8c49336"

0 commit comments

Comments
 (0)