-
Notifications
You must be signed in to change notification settings - Fork 27
Closed
Labels
Description
Since userInteraction is set on keydown/paste/wheel/drop and none of those are triggered on touch devices, the autonumeric behavior is strange.
It results in empty value not being set and decimals being inserted on every key, which makes it almost impossible to enter values.
The solution is actually quite simple.
userInteraction is only used in one check, that could be replaced.
current code:
if (!this.userInteraction) {
// Make sure this is only called when the value is set by an external script, and not from a user input
// The modification comes from a script, so we need to reformat the new value `newValue`
if (newValue.value !== oldValue.value) {
// Compare the 'newValue' with the current 'oldValue' so we do not `set` it again if it's not needed
//XXX If multiple components share the same v-model, this means 'set' here will be called as many times as there is an input that is not being used by a human interaction
this.anElement.set(newValue.value);
}
}
solution:
if (this.anElement.getNumber() !== newValue.value) {
// Make sure this is only called when the value is set by an external script, and not from a user input
// The modification comes from a script, so we need to reformat the new value `newValue`
if (newValue.value !== oldValue.value) {
// Compare the 'newValue' with the current 'oldValue' so we do not `set` it again if it's not needed
//XXX If multiple components share the same v-model, this means 'set' here will be called as many times as there is an input that is not being used by a human interaction
this.anElement.set(newValue.value);
}
}
userInteraction can therefor be removed completely.