Skip to content

Commit

Permalink
feat(b-dropdown-form): add formClass prop for adding classes to the f…
Browse files Browse the repository at this point in the history
…orm element (closes #4474) (#4475)
  • Loading branch information
bbugh authored and tmorehouse committed Dec 9, 2019
1 parent 5e216f6 commit eef4200
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/dropdown/dropdown-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export const BDropdownForm = /*#__PURE__*/ Vue.extend({
disabled: {
type: Boolean,
default: false
},
formClass: {
type: [String, Object, Array],
default: null
}
},
render(h, { props, data, children }) {
Expand All @@ -24,7 +28,7 @@ export const BDropdownForm = /*#__PURE__*/ Vue.extend({
{
ref: 'form',
staticClass: 'b-dropdown-form',
class: { disabled: props.disabled },
class: [props.formClass, { disabled: props.disabled }],
props,
attrs: {
...$attrs,
Expand Down
11 changes: 11 additions & 0 deletions src/components/dropdown/dropdown-form.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ describe('dropdown-form', () => {
expect(form.classes()).not.toContain('disabled')
})

it('should have custom form classes on form', async () => {
const wrapper = mount(BDropdownForm, {
propsData: {
formClass: ['form-class-custom', 'form-class-custom-2']
}
})

const form = wrapper.find('form')
expect(form.classes()).toEqual(['b-dropdown-form', 'form-class-custom', 'form-class-custom-2'])
})

it('has tabindex on form', async () => {
const wrapper = mount(BDropdownForm)
expect(wrapper.is('li')).toBe(true)
Expand Down
5 changes: 5 additions & 0 deletions src/components/dropdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@
{
"prop": "validated",
"description": "When set, adds the Bootstrap class 'was-validated' on the form, triggering the native browser validation states"
},
{
"prop": "formClass",
"version": "2.2.0",
"description": "CSS class (or classes) to add to the form"
}
]
},
Expand Down

0 comments on commit eef4200

Please sign in to comment.