Skip to content
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

fix(inputs): reset value to null instead of undefined #12373

Merged
merged 3 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export default VSelect.extend({
this.selectedIndex = nextIndex
},
clearableCallback () {
this.internalSearch = undefined
this.internalSearch = null

VSelect.options.methods.clearableCallback.call(this)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ describe('VAutocomplete.ts', () => {

icon.trigger('click')

expect(wrapper.vm.internalSearch).toBeUndefined()
expect(wrapper.vm.internalSearch).toBeNull()
})

it('should propagate content class', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VCombobox/VCombobox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export default VAutocomplete.extend({

// Reset search if using slot
// to avoid a double input
if (isUsingSlot) this.internalSearch = undefined
if (isUsingSlot) this.internalSearch = null
},
updateSelf () {
this.multiple ? this.updateTags() : this.updateCombobox()
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VFileInput/VFileInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export default VTextField.extend({

methods: {
clearableCallback () {
this.internalValue = this.isMultiple ? [] : undefined
this.internalValue = this.isMultiple ? [] : null
this.$refs.input.value = ''
},
genChips () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('VFileInput.ts', () => {
})

wrapper.vm.clearableCallback()
expect(wrapper.vm.internalValue).toBeUndefined()
expect(wrapper.vm.internalValue).toBeNull()

const wrapper2 = mountFunction({
attrs: { multiple: '' },
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/components/VSelect/VSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export default baseMixins.extend<options>().extend({
this.isMenuActive = true
},
clearableCallback () {
this.setValue(this.multiple ? [] : undefined)
this.setValue(this.multiple ? [] : null)
this.setMenuIndex(-1)
this.$nextTick(() => this.$refs.input && this.$refs.input.focus())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ describe('VSelect.ts', () => {

await wrapper.vm.$nextTick()

expect(wrapper.vm.internalValue).toBeUndefined()
expect(input).toHaveBeenCalledWith(undefined)
expect(wrapper.vm.internalValue).toBeNull()
expect(input).toHaveBeenCalledWith(null)
})

it('should be clearable with prop, dirty and single select', async () => {
Expand All @@ -292,7 +292,7 @@ describe('VSelect.ts', () => {

clear.trigger('click')
await wrapper.vm.$nextTick()
expect(wrapper.vm.internalValue).toBeUndefined()
expect(wrapper.vm.internalValue).toBeNull()
expect(wrapper.vm.isMenuActive).toBe(false)
})

Expand Down
10 changes: 0 additions & 10 deletions packages/vuetify/src/components/VSelect/__tests__/VSelect4.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,8 @@ describe('VSelect.ts', () => {
},
})

const icon = wrapper.find('.v-input__append-inner .v-icon')

expect(wrapper.vm.selectedItems).toHaveLength(1)
expect(wrapper.vm.isDirty).toBe(true)

icon.trigger('click')

await wrapper.vm.$nextTick()

expect(wrapper.vm.selectedItems).toHaveLength(0)
expect(wrapper.vm.isDirty).toBe(false)
expect(wrapper.vm.internalValue).toBeUndefined()
})

it('should only calls change once when clearing', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ describe('validatable.ts', () => {
wrapper.vm.reset()

expect(wrapper.vm.isResetting).toBe(true)
expect(wrapper.vm.internalValue).toBeUndefined()
expect(wrapper.vm.internalValue).toBeNull()

wrapper.setProps({ value: ['foobar'] })

Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/mixins/validatable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export default baseMixins.extend({
this.isResetting = true
this.internalValue = Array.isArray(this.internalValue)
? []
: undefined
: null
},
/** @public */
resetValidation () {
Expand Down