input: apply decimals number before checking the value against the validation expression

This commit is contained in:
bordun 2020-12-02 11:20:16 +01:00
parent 6b68000079
commit 52c933c7c8
2 changed files with 8 additions and 7 deletions

View file

@ -5,6 +5,7 @@
- bug fixes
- editor: cloned `dropdown` and `input` widgets not opening when selected
- widgets: prevent value-stateless widgets (tap buttons, clone, scripts, html and svg) from sending a value for cross-client synchronization (leads to unexpected script execution) and exclude them from state saves
- input: apply `decimals` number before checking the value against the `validation` expression
## 1.7.3

View file

@ -139,7 +139,7 @@ class Input extends Canvas {
setValue(v, options={} ) {
if (this.validation && !String(v).match(this.validation)) {
if (this.validation && !this.getStringValue(v).match(this.validation)) {
this.input.value = this.value
return
}
@ -152,7 +152,7 @@ class Input extends Canvas {
if (this.value === '' || this.value === null) this.value = this.getProp('default')
this.stringValue = this.getStringValue()
this.stringValue = this.getStringValue(this.value)
this.batchDraw()
if (options.send && !options.fromSync) this.sendValue()
@ -184,11 +184,11 @@ class Input extends Canvas {
}
getStringValue() {
if (this.value === undefined) return ''
return typeof this.value != 'string' ?
JSON.stringify(deepCopy(this.value, this.decimals)).replace(/,/g, ', ') :
this.value
getStringValue(v) {
if (v === undefined) return ''
return typeof v != 'string' ?
JSON.stringify(deepCopy(v, this.decimals)).replace(/,/g, ', ') :
v
}
}