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

Commit 389b300

Browse files
committed
Update nav-item-dropdown.js
1 parent 02778f6 commit 389b300

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

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

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ import dropdownMixin from '../../mixins/dropdown'
55
import idMixin from '../../mixins/id'
66
import normalizeSlotMixin from '../../mixins/normalize-slot'
77
import { props as BDropdownProps } from '../dropdown/dropdown'
8-
import { BLink } from '../link/link'
8+
import { BLink, props as BLinkProps } from '../link/link'
99

1010
// --- Props ---
11-
export const props = pluckProps(
12-
['text', 'html', 'menuClass', 'toggleClass', 'noCaret', 'role', 'lazy'],
13-
BDropdownProps
14-
)
11+
export const props = {
12+
...pluckProps(
13+
['text', 'html', 'menuClass', 'toggleClass', 'noCaret', 'role', 'lazy'],
14+
BDropdownProps
15+
),
16+
...pluckProps(['href'], BLinkProps)
17+
}
1518

1619
// --- Main component ---
1720
// @vue/component
@@ -20,6 +23,9 @@ export const BNavItemDropdown = /*#__PURE__*/ Vue.extend({
2023
mixins: [idMixin, dropdownMixin, normalizeSlotMixin],
2124
props,
2225
computed: {
26+
buttonId() {
27+
return this.safeId('_BV_button_')
28+
},
2329
isNav() {
2430
// Signal to dropdown mixin that we are in a navbar
2531
return true
@@ -41,23 +47,29 @@ export const BNavItemDropdown = /*#__PURE__*/ Vue.extend({
4147
}
4248
},
4349
render(h) {
50+
const { buttonId, visible } = this
51+
4452
const $button = h(
4553
BLink,
4654
{
47-
ref: 'toggle',
4855
staticClass: 'nav-link dropdown-toggle',
4956
class: this.toggleClasses,
50-
props: { disabled: this.disabled },
57+
props: {
58+
href: this.href || `#${buttonId}`,
59+
disabled: this.disabled
60+
},
5161
attrs: {
52-
id: this.safeId('_BV_button_'),
62+
id: buttonId,
63+
role: 'button',
5364
'aria-haspopup': 'true',
54-
'aria-expanded': this.visible ? 'true' : 'false'
65+
'aria-expanded': visible ? 'true' : 'false'
5566
},
5667
on: {
5768
mousedown: this.onMousedown,
5869
click: this.toggle,
5970
keydown: this.toggle // Handle ENTER, SPACE and DOWN
60-
}
71+
},
72+
ref: 'toggle'
6173
},
6274
[
6375
this.$slots['button-content'] ||
@@ -71,16 +83,16 @@ export const BNavItemDropdown = /*#__PURE__*/ Vue.extend({
7183
{
7284
staticClass: 'dropdown-menu',
7385
class: this.menuClasses,
74-
ref: 'menu',
7586
attrs: {
7687
tabindex: '-1',
77-
'aria-labelledby': this.safeId('_BV_button_')
88+
'aria-labelledby': buttonId
7889
},
7990
on: {
8091
keydown: this.onKeydown // Handle UP, DOWN and ESC
81-
}
92+
},
93+
ref: 'menu'
8294
},
83-
!this.lazy || this.visible ? this.normalizeSlot('default', { hide: this.hide }) : [h()]
95+
!this.lazy || visible ? this.normalizeSlot('default', { hide: this.hide }) : [h()]
8496
)
8597

8698
return h(

0 commit comments

Comments
 (0)