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

Commit eef4200

Browse files
bbughtmorehouse
authored andcommitted
feat(b-dropdown-form): add formClass prop for adding classes to the form element (closes #4474) (#4475)
1 parent 5e216f6 commit eef4200

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/components/dropdown/dropdown-form.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ export const BDropdownForm = /*#__PURE__*/ Vue.extend({
1111
disabled: {
1212
type: Boolean,
1313
default: false
14+
},
15+
formClass: {
16+
type: [String, Object, Array],
17+
default: null
1418
}
1519
},
1620
render(h, { props, data, children }) {
@@ -24,7 +28,7 @@ export const BDropdownForm = /*#__PURE__*/ Vue.extend({
2428
{
2529
ref: 'form',
2630
staticClass: 'b-dropdown-form',
27-
class: { disabled: props.disabled },
31+
class: [props.formClass, { disabled: props.disabled }],
2832
props,
2933
attrs: {
3034
...$attrs,

src/components/dropdown/dropdown-form.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ describe('dropdown-form', () => {
2020
expect(form.classes()).not.toContain('disabled')
2121
})
2222

23+
it('should have custom form classes on form', async () => {
24+
const wrapper = mount(BDropdownForm, {
25+
propsData: {
26+
formClass: ['form-class-custom', 'form-class-custom-2']
27+
}
28+
})
29+
30+
const form = wrapper.find('form')
31+
expect(form.classes()).toEqual(['b-dropdown-form', 'form-class-custom', 'form-class-custom-2'])
32+
})
33+
2334
it('has tabindex on form', async () => {
2435
const wrapper = mount(BDropdownForm)
2536
expect(wrapper.is('li')).toBe(true)

src/components/dropdown/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@
256256
{
257257
"prop": "validated",
258258
"description": "When set, adds the Bootstrap class 'was-validated' on the form, triggering the native browser validation states"
259+
},
260+
{
261+
"prop": "formClass",
262+
"version": "2.2.0",
263+
"description": "CSS class (or classes) to add to the form"
259264
}
260265
]
261266
},

0 commit comments

Comments
 (0)