Skip to content

Commit 21a822b

Browse files
authored
feat(b-form-group): allow setting label cols props to auto (closes bootstrap-vue#4217) (bootstrap-vue#4218)
1 parent 605d4c4 commit 21a822b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/components/form-group/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ By default, the label appears above the input element(s), but you may optionally
7979
(label to the left of the input) at the various standard Bootstrap breakpoints.
8080

8181
The props`label-cols` and `label-cols-{breakpoint}` allow you to specify how many columns the label
82-
should occupy in the row. The input(s) will fill the rest of the row. The value must be a number
82+
should occupy in the row. The input will fill the rest of the row width. The value must be a number
8383
greater than `0`. Or you can set the prop to `true` to make the label and input(s) each occupy half
84-
of the width of the rendered row (handy if you have custom Bootstrap with an odd number of columns).
84+
of the width of the rendered row (handy if you have custom Bootstrap with an odd number of columns),
85+
or set the value to `'auto'` so that the label occupies only the width that is needed.
8586

8687
| prop | description |
8788
| --------------- | --------------------------------- |
@@ -107,6 +108,8 @@ of the width of the rendered row (handy if you have custom Bootstrap with an odd
107108
</div>
108109
</div>
109110

111+
The ability to set the label cols to `'auto'` was added in BootstrapVue version <samp>2.1.0</samp>.
112+
110113
<!-- b-form-group-horizontal.vue -->
111114
```
112115

@@ -228,7 +231,7 @@ of related form controls:
228231
Setting the `disabled` prop will disable the rendered `<fieldset>` and, on most browsers, will
229232
disable all the input elements contained within the fieldset.
230233

231-
`disabled` has no effect when `label-for` is set (as a `fieldset` element is not rendered).
234+
`disabled` has no effect when `label-for` is set (as a `<fieldset>` element is not rendered).
232235

233236
## Validation state feedback
234237

src/components/form-group/form-group.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ export const BFormGroup = {
258258
// Handle case where the prop's value is an empty string,
259259
// which represents true
260260
propVal = propVal === '' ? true : propVal || false
261-
if (!isBoolean(propVal)) {
261+
if (!isBoolean(propVal) && propVal !== 'auto') {
262262
// Convert to column size to number
263263
propVal = parseInt(propVal, 10) || 0
264264
// Ensure column size is greater than 0

0 commit comments

Comments
 (0)