Skip to content

Commit cb4fb0d

Browse files
author
Nathan Reyes
committed
Fix bug where slot method 'updateValue' not working.
1 parent b71bd91 commit cb4fb0d

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## Bug Fixes
2+
### `v-date-picker`
3+
* Fixes bug where calling slot method `updateValue` with `formatInput: false` was not working.
4+
* Rename `update-on-input-keyup` prop to simply `update-on-input`.
5+
6+
### `defaults`
7+
* Rename `datePickerUpdateOnInputKeyup` to simply `datePickerUpdateOnInput`.
8+
19
# v0.9.5
210
## Improvements
311
### `v-calendar`

src/components/DatePicker.vue

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default {
8686
...this.inputAttrs,
8787
},
8888
on: {
89-
input: event => (this.inputValue = event.target.value),
89+
input: this.inputInput,
9090
change: this.inputChange,
9191
keyup: this.inputKeyup,
9292
},
@@ -113,9 +113,9 @@ export default {
113113
availableDates: null,
114114
formats: Object, // Resolved by computed property
115115
inputProps: { type: Object, default: () => ({}) }, // Resolved by computed property
116-
updateOnInputKeyup: {
116+
updateOnInput: {
117117
type: Boolean,
118-
default: () => defaults.datePickerUpdateOnInputKeyup,
118+
default: () => defaults.datePickerUpdateOnInput,
119119
},
120120
tintColor: { type: String, default: () => defaults.datePickerTintColor },
121121
dragAttribute: Object, // Resolved by computed property
@@ -415,6 +415,15 @@ export default {
415415
}
416416
}
417417
},
418+
inputInput(e) {
419+
this.inputValue = e.target.value;
420+
if (this.updateOnInput) {
421+
this.updateValue(this.inputValue, {
422+
formatInput: false,
423+
hidePopover: false,
424+
});
425+
}
426+
},
418427
inputChange() {
419428
// Enter key, blur or other change events
420429
this.updateValue(this.inputValue, {
@@ -429,21 +438,17 @@ export default {
429438
formatInput: true,
430439
hidePopover: true,
431440
});
432-
// All other keys
433-
} else if (e.keyCode !== 13 && this.updateOnInputKeyup) {
434-
this.updateValue(this.inputValue, {
435-
formatInput: false,
436-
hidePopover: false,
437-
});
438441
}
439442
},
440443
updateValue(
441444
value = this.inputValue,
442445
{
443-
formatInput = true,
446+
formatInput = false,
444447
hidePopover = !this.popoverKeepVisibleOnInput,
445448
} = {},
446449
) {
450+
// Reassign input value for good measure
451+
this.inputValue = isString(value) ? value : this.inputValue;
447452
// Parse value if needed
448453
const parsedValue = isString(value)
449454
? this.profile.parseValue(value)

src/utils/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const defaults = {
4141
placeholder: `${format} - ${format}`,
4242
}),
4343
}),
44-
datePickerUpdateOnInputKeyup: false,
44+
datePickerUpdateOnInput: false,
4545
datePickerTintColor: '#66B3CC',
4646
datePickerShowCaps: false,
4747
datePickerShowDayPopover: true,

0 commit comments

Comments
 (0)