Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(b-form-*) remove supplying a string to state prop #3880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/components/form-checkbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,14 +477,14 @@ Bootstrap includes validation styles for `valid` and `invalid` states on most fo

Generally speaking, you'll want to use a particular state for specific types of feedback:

- `'invalid'` (or `false`) is great for when there's a blocking or required field. A user must fill
in this field properly to submit the form.
- `'valid'` (or `true`) is ideal for situations when you have per-field validation throughout a form
and want to encourage a user through the rest of the fields.
- `null` Displays no validation state

To apply one of the contextual state icons on `<b-form-checkbox>`, set the `state` prop to
`'invalid'` (or `false`), `'valid'` (or `true`), or `null`.
- `false` (denotes invalid state) is great for when there's a blocking or required field. A user
must fill in this field properly to submit the form.
- `true` (denotes valid state) is ideal for situations when you have per-field validation
throughout a form and want to encourage a user through the rest of the fields.
- `null` Displays no validation state (neither valid nor invalid)

To apply one of the contextual state icons on `<b-form-checkbox>`, set the `state` prop to `false`
(for invalid), `true` (for valid), or `null` (no validation state).

**Note:** Contextual states are **not** supported when in button mode.

Expand Down
74 changes: 0 additions & 74 deletions src/components/form-checkbox/form-checkbox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,24 +364,6 @@ describe('form-checkbox', () => {
wrapper.destroy()
})

it('default has input validation class is-valid when state="valid"', async () => {
const wrapper = mount(BFormCheckbox, {
propsData: {
state: 'valid',
checked: false
},
slots: {
default: 'foobar'
}
})
const input = wrapper.find('input')
expect(input).toBeDefined()
expect(input.classes()).not.toContain('is-invalid')
expect(input.classes()).toContain('is-valid')

wrapper.destroy()
})

it('default has input validation class is-invalid when state=false', async () => {
const wrapper = mount(BFormCheckbox, {
propsData: {
Expand All @@ -400,24 +382,6 @@ describe('form-checkbox', () => {
wrapper.destroy()
})

it('default has input validation class is-invalid when state="invalid"', async () => {
const wrapper = mount(BFormCheckbox, {
propsData: {
state: 'invalid',
checked: false
},
slots: {
default: 'foobar'
}
})
const input = wrapper.find('input')
expect(input).toBeDefined()
expect(input.classes()).toContain('is-invalid')
expect(input.classes()).not.toContain('is-valid')

wrapper.destroy()
})

// --- Plain styling ---

it('plain has structure <div><input><label></label></div>', async () => {
Expand Down Expand Up @@ -610,25 +574,6 @@ describe('form-checkbox', () => {
wrapper.destroy()
})

it('plain has input validation class is-valid when state="valid"', async () => {
const wrapper = mount(BFormCheckbox, {
propsData: {
state: 'valid',
plain: true,
checked: false
},
slots: {
default: 'foobar'
}
})
const input = wrapper.find('input')
expect(input).toBeDefined()
expect(input.classes()).not.toContain('is-invalid')
expect(input.classes()).toContain('is-valid')

wrapper.destroy()
})

it('plain has input validation class is-invalid when state=false', async () => {
const wrapper = mount(BFormCheckbox, {
propsData: {
Expand All @@ -648,25 +593,6 @@ describe('form-checkbox', () => {
wrapper.destroy()
})

it('plain has input validation class is-invalid when state="invalid"', async () => {
const wrapper = mount(BFormCheckbox, {
propsData: {
state: 'invalid',
plain: true,
checked: false
},
slots: {
default: 'foobar'
}
})
const input = wrapper.find('input')
expect(input).toBeDefined()
expect(input.classes()).toContain('is-invalid')
expect(input.classes()).not.toContain('is-valid')

wrapper.destroy()
})

// --- Switch styling - stand alone ---

it('switch has structure <div><input><label></label></div>', async () => {
Expand Down
18 changes: 10 additions & 8 deletions src/components/form-file/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,16 @@ Bootstrap includes validation styles for `valid` and `invalid` states on most fo

Generally speaking, you'll want to use a particular state for specific types of feedback:

- `'invalid'` is great for when there's a blocking or required field. A user must fill in this field
properly to submit the form.
- `'valid'` is ideal for situations when you have per-field validation throughout a form and want to
encourage a user through the rest of the fields.
- `null` Displays no validation state

To apply one of the contextual state icons on `<b-form-file`, set the `state` prop to `'invalid'`
(or `false`), `'valid'` ( or `true`), or `null`.
- `false` (denotes invalid state) is great for when there's a blocking or required field. A user
must fill in this field properly to submit the form.
- `true` (denotes valid state) is ideal for situations when you have per-field validation
throughout a form and want to encourage a user through the rest of the fields.
- `null` Displays no validation state (neither valid nor invalid)

To apply one of the contextual state icons on `<b-form-file>`, set the `state` prop to `false`
(for invalid), `true` (for valid), or `null` (no validation state).

**Note:** Contextual states are **not** supported when in button mode.

## Autofocus

Expand Down
17 changes: 7 additions & 10 deletions src/components/form-group/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,14 @@ Bootstrap includes validation styles for `valid` and `invalid` states on most fo

Generally speaking, you'll want to use a particular state for specific types of feedback:

- `'invalid'` is great for when there's a blocking or required field. A user must fill in this field
properly to submit the form.
- `'valid'` is ideal for situations when you have per-field validation throughout a form and want to
encourage a user through the rest of the fields.
- `null` Displays no validation state
- `false` (denotes invalid state) is great for when there's a blocking or required field. A user
must fill in this field properly to submit the form.
- `true` (denotes valid state) is ideal for situations when you have per-field validation
throughout a form and want to encourage a user through the rest of the fields.
- `null` Displays no validation state (neither valid nor invalid)

To apply one of the contextual states on `<b-form-group>`, set the `state` prop to `'invalid'` (or
`false`), `'valid'` (or `true`), or `null`. This will programmatically show the appropriate feedback
text.
To apply one of the contextual state icons on `<b-form-group>`, set the `state` prop to `false`
(for invalid), `true` (for valid), or `null` (no validation state).

Bootstrap v4 uses sibling CSS selectors of `:invalid` or `:valid` inputs to show the feedback text.
Some form controls (such as checkboxes, radios, and file inputs, or inputs inside input-groups) are
Expand All @@ -269,8 +268,6 @@ setting the prop `invalid-feedback` or using the named slot `invalid-feedback`.
Invalid feedback is rendered using the
[`<b-form-invalid-feedback>`](/docs/components/form#helper-components) form sub-component.

**Note:** The prop `feedback` has been deprecated in favor of the `invalid-feedback` prop.

### Valid feedback

Show optional valid state feedback text to provide textual state feedback (html supported) by
Expand Down
25 changes: 11 additions & 14 deletions src/components/form-input/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,14 @@ Bootstrap includes validation styles for `valid` and `invalid` states on most fo

Generally speaking, you'll want to use a particular state for specific types of feedback:

- `'invalid'` (or `false`) is great for when there's a blocking or required field. A user must fill
in this field properly to submit the form.
- `'valid'` (or `true`) is ideal for situations when you have per-field validation throughout a form
and want to encourage a user through the rest of the fields.
- `null` Displays no validation state
- `false` (denotes invalid state) is great for when there's a blocking or required field. A user
must fill in this field properly to submit the form.
- `true` (denotes valid state) is ideal for situations when you have per-field validation
throughout a form and want to encourage a user through the rest of the fields.
- `null` Displays no validation state (neither valid nor invalid)

To apply one of the contextual state icons on `<b-form-input>`, set the `state` prop to:

- The string `'invalid'` or boolean `false` for invalid contextual state
- The string `'valid'` or boolean `true` for the valid contextual state
- `null` for no validation contextual state (default)
To apply one of the contextual state icons on `<b-form-input>`, set the `state` prop to `false`
(for invalid), `true` (for valid), or `null` (no validation state).

```html
<b-container fluid>
Expand Down Expand Up @@ -314,16 +311,16 @@ text block.
Specifically for assistive technologies, invalid form controls can also be assigned an
`aria-invalid="true"` attribute.

When `<b-form-input>` has an invalid contextual state (i.e. `'invalid'` or `false`) you may also
want to set the `<b-form-input>` prop `aria-invalid` to `true`, or to one of the supported values:
When `<b-form-input>` has an invalid contextual state (i.e. state is `false`) you may also want
to set the `<b-form-input>` prop `aria-invalid` to `true`, or to one of the supported values:

- `false`: Convey no errors detected (default)
- `true` (or `'true'`): Convey that the value has failed validation.
- `'grammar'` Convey that a grammatical error has been detected.
- `'spelling'` Convey that a spelling error has been detected.

If `aria-invalid` is not explicitly set and `state` is set to `false` (or `'invalid'`), then the
`aria-invalid` attribute on the input will automatically be set to `'true'`;
If `aria-invalid` is not explicitly set and `state` is set to `false`, then the `aria-invalid`
attribute on the input will automatically be set to `'true'`;

## Formatter support

Expand Down
39 changes: 0 additions & 39 deletions src/components/form-input/form-input.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,19 +230,6 @@ describe('form-input', () => {
wrapper.destroy()
})

it('does not have is-valid or is-invalid classes when state=""', async () => {
const wrapper = mount(BFormInput, {
propsData: {
state: ''
}
})
const input = wrapper.find('input')
expect(input.classes()).not.toContain('is-valid')
expect(input.classes()).not.toContain('is-invalid')

wrapper.destroy()
})

it('has class is-valid when state=true', async () => {
const wrapper = mount(BFormInput, {
propsData: {
Expand All @@ -256,19 +243,6 @@ describe('form-input', () => {
wrapper.destroy()
})

it('has class is-valid when state="valid"', async () => {
const wrapper = mount(BFormInput, {
propsData: {
state: 'valid'
}
})
const input = wrapper.find('input')
expect(input.classes()).toContain('is-valid')
expect(input.classes()).not.toContain('is-invalid')

wrapper.destroy()
})

it('has class is-invalid when state=false', async () => {
const wrapper = mount(BFormInput, {
propsData: {
Expand All @@ -282,19 +256,6 @@ describe('form-input', () => {
wrapper.destroy()
})

it('has class is-invalid when state="invalid"', async () => {
const wrapper = mount(BFormInput, {
propsData: {
state: 'invalid'
}
})
const input = wrapper.find('input')
expect(input.classes()).toContain('is-invalid')
expect(input.classes()).not.toContain('is-valid')

wrapper.destroy()
})

it('does not have aria-invalid attribute by default', async () => {
const wrapper = mount(BFormInput)
expect(wrapper.contains('[aria-invalid]')).toBe(false)
Expand Down
20 changes: 10 additions & 10 deletions src/components/form-radio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,14 @@ Bootstrap includes validation styles for `valid` and `invalid` states on most fo

Generally speaking, you'll want to use a particular state for specific types of feedback:

- `'invalid'` is great for when there's a blocking or required field. A user must fill in this field
properly to submit the form.
- `'valid'` is ideal for situations when you have per-field validation throughout a form and want to
encourage a user through the rest of the fields.
- `null` Displays no validation state
- `false` (denotes invalid state) is great for when there's a blocking or required field. A user
must fill in this field properly to submit the form.
- `true` (denotes valid state) is ideal for situations when you have per-field validation
throughout a form and want to encourage a user through the rest of the fields.
- `null` Displays no validation state (neither valid nor invalid)

To apply one of the contextual state icons on `<b-form-radio>`, set the `state` prop to `'invalid'`
(or `false`), `'valid'` (or `true`), or `null`.
To apply one of the contextual state icons on `<b-form-radio>`, set the `state` prop to `false`
(for invalid), `true` (for valid), or `null` (no validation state).

**Note:** Contextual state is not supported for radios rendered in buttons mode.

Expand Down Expand Up @@ -417,14 +417,14 @@ controls can also be assigned an `aria-invalid="true"` attribute (see below).

### ARIA `aria-invalid` attribute

When `<b-form-radio-group>` has an invalid contextual state (i.e. `invalid`) you may also want to
set the `<b-form-radio-group>` prop `aria-invalid` to `true`.
When `<b-form-radio-group>` has an invalid contextual state (i.e. state = `false`) you may also want
to set the `<b-form-radio-group>` prop `aria-invalid` to `true`.

Supported `aria-invalid` values are:

- `false` (default) No errors detected
- `true` The value has failed validation.

`aria-invalid` is automatically set to `true` if the `state` prop is `'invalid'` (or `false`).
`aria-invalid` is automatically set to `true` if the `state` prop is `false`.

<!-- Component reference added automatically from component package.json -->
Loading