Skip to content

Commit 81efb89

Browse files
authored
fix(b-dropdown-*): ensure class bindings are placed on root element for all dropdown sub-components (closes #4022) (#4024)
1 parent c7cb16f commit 81efb89

File tree

5 files changed

+40
-30
lines changed

5 files changed

+40
-30
lines changed

src/components/dropdown/dropdown-divider.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,20 @@ export const props = {
1212
export const BDropdownDivider = /*#__PURE__*/ Vue.extend({
1313
name: 'BDropdownDivider',
1414
functional: true,
15-
inheritAttrs: false,
1615
props,
1716
render(h, { props, data }) {
18-
return h('li', { attrs: { role: 'presentation' } }, [
19-
h(
20-
props.tag,
21-
mergeData(data, {
22-
staticClass: 'dropdown-divider',
23-
attrs: {
24-
role: 'separator',
25-
'aria-orientation': 'horizontal'
26-
},
27-
ref: 'divider'
28-
})
29-
)
17+
const $attrs = data.attrs || {}
18+
data.attrs = {}
19+
return h('li', mergeData(data, { attrs: { role: 'presentation' } }), [
20+
h(props.tag, {
21+
staticClass: 'dropdown-divider',
22+
attrs: {
23+
...$attrs,
24+
role: 'separator',
25+
'aria-orientation': 'horizontal'
26+
},
27+
ref: 'divider'
28+
})
3029
])
3130
}
3231
})

src/components/dropdown/dropdown-form.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { BForm, props as formProps } from '../form/form'
55
export const BDropdownForm = /*#__PURE__*/ Vue.extend({
66
name: 'BDropdownForm',
77
functional: true,
8-
inheritAttrs: false,
98
props: {
109
...formProps,
1110
disabled: {
@@ -14,20 +13,26 @@ export const BDropdownForm = /*#__PURE__*/ Vue.extend({
1413
}
1514
},
1615
render(h, { props, data, children }) {
17-
return h('li', { attrs: { role: 'presentation' } }, [
16+
const $attrs = data.attrs || {}
17+
const $listeners = data.on || {}
18+
data.attrs = {}
19+
data.on = {}
20+
return h('li', mergeData(data, { attrs: { role: 'presentation' } }), [
1821
h(
1922
BForm,
20-
mergeData(data, {
23+
{
2124
ref: 'form',
2225
staticClass: 'b-dropdown-form',
2326
class: { disabled: props.disabled },
2427
props,
2528
attrs: {
29+
...$attrs,
2630
disabled: props.disabled,
2731
// Tab index of -1 for keyboard navigation
2832
tabindex: props.disabled ? null : '-1'
29-
}
30-
}),
33+
},
34+
on: $listeners
35+
},
3136
children
3237
)
3338
])

src/components/dropdown/dropdown-group.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ export const props = {
3333
export const BDropdownGroup = /*#__PURE__*/ Vue.extend({
3434
name: 'BDropdownGroup',
3535
functional: true,
36-
inheritAttrs: false,
3736
props,
3837
render(h, { props, data, slots, scopedSlots }) {
3938
const $slots = slots()
4039
const $scopedSlots = scopedSlots || {}
40+
const $attrs = data.attrs || {}
41+
data.attrs = {}
4142
let header
4243
let headerId = null
4344

@@ -62,18 +63,19 @@ export const BDropdownGroup = /*#__PURE__*/ Vue.extend({
6263
.join(' ')
6364
.trim()
6465

65-
return h('li', { attrs: { role: 'presentation' } }, [
66+
return h('li', mergeData(data, { attrs: { role: 'presentation' } }), [
6667
header || h(),
6768
h(
6869
'ul',
69-
mergeData(data, {
70+
{
7071
staticClass: 'list-unstyled',
7172
attrs: {
73+
...$attrs,
7274
id: props.id || null,
7375
role: 'group',
7476
'aria-describedby': adb || null
7577
}
76-
}),
78+
},
7779
normalizeSlot('default', {}, $scopedSlots, $slots)
7880
)
7981
])

src/components/dropdown/dropdown-header.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,25 @@ export const props = {
2020
export const BDropdownHeader = /*#__PURE__*/ Vue.extend({
2121
name: 'BDropdownHeader',
2222
functional: true,
23-
inheritAttrs: false,
2423
props,
2524
render(h, { props, data, children }) {
26-
return h('li', { attrs: { role: 'presentation' } }, [
25+
const $attrs = data.attrs || {}
26+
data.attrs = {}
27+
return h('li', mergeData(data, { attrs: { role: 'presentation' } }), [
2728
h(
2829
props.tag,
29-
mergeData(data, {
30+
{
3031
staticClass: 'dropdown-header',
3132
class: {
3233
[`text-${props.variant}`]: props.variant
3334
},
3435
attrs: {
36+
...$attrs,
3537
id: props.id || null,
3638
role: 'heading'
3739
},
3840
ref: 'header'
39-
}),
41+
},
4042
children
4143
)
4244
])

src/components/dropdown/dropdown-text.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { mergeData } from 'vue-functional-data-merge'
55
export const BDropdownText = /*#__PURE__*/ Vue.extend({
66
name: 'BDropdownText',
77
functional: true,
8-
inheritAttrs: false,
98
props: {
109
tag: {
1110
type: String,
@@ -17,17 +16,20 @@ export const BDropdownText = /*#__PURE__*/ Vue.extend({
1716
}
1817
},
1918
render(h, { props, data, children }) {
20-
return h('li', { attrs: { role: 'presentation' } }, [
19+
const $attrs = data.attrs || {}
20+
data.attrs = {}
21+
return h('li', mergeData(data, { attrs: { role: 'presentation' } }), [
2122
h(
2223
props.tag,
23-
mergeData(data, {
24+
{
2425
staticClass: 'b-dropdown-text',
2526
class: {
2627
[`text-${props.variant}`]: props.variant
2728
},
2829
props,
30+
attrs: $attrs,
2931
ref: 'text'
30-
}),
32+
},
3133
children
3234
)
3335
])

0 commit comments

Comments
 (0)