Skip to content

Commit d6982a1

Browse files
Adds blur event to value error-behavior
1 parent 7d98a3c commit d6982a1

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

dist/formulate.esm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formulate.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formulate.umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/libs/context.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ function slotProps () {
500500
* Bound into the context object.
501501
*/
502502
function blurHandler () {
503-
if (this.errorBehavior === 'blur') {
503+
if (this.errorBehavior === 'blur' || this.errorBehavior === 'value') {
504504
this.behavioralErrorVisibility = true
505505
}
506506
}

test/unit/FormulateInput.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,17 @@ describe('FormulateInput', () => {
420420
expect(wrapper.find('.formulate-input-errors').exists()).toBeFalsy()
421421
})
422422

423+
it('shows errors when error-behavior is value and an input is blurred', async () => {
424+
const wrapper = mount(FormulateInput, { propsData: {
425+
type: 'text',
426+
validation: 'required',
427+
errorBehavior: 'value',
428+
} })
429+
wrapper.find('input').trigger('blur')
430+
await flushPromises()
431+
expect(wrapper.find('.formulate-input-errors').exists()).toBeTruthy()
432+
})
433+
423434
it('shows errors initially when error-behavior is value and it has a value', async () => {
424435
const wrapper = mount(FormulateInput, { propsData: {
425436
type: 'text',

0 commit comments

Comments
 (0)