Skip to content

Commit 456f0d6

Browse files
authored
Tariff UI: fix decimal price input (#27950)
1 parent f24dcd5 commit 456f0d6

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

assets/js/components/Config/PropertyField.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<div class="position-relative flex-grow-1">
8484
<input
8585
:id="id"
86-
v-model="value"
86+
:value="value"
8787
:list="datalistId"
8888
:type="inputType"
8989
:step="step"
@@ -98,6 +98,8 @@
9898
"
9999
:autocomplete="masked || datalistId ? 'off' : null"
100100
:disabled="disabled"
101+
@change="onFieldChange"
102+
@input="onFieldInput"
101103
/>
102104
<button
103105
v-if="showClearButton"
@@ -346,6 +348,20 @@ export default {
346348
},
347349
},
348350
methods: {
351+
coerceValue(val) {
352+
if (this.inputType === "number") {
353+
return val === "" ? "" : Number(val);
354+
}
355+
return val;
356+
},
357+
onFieldChange(e) {
358+
this.value = this.coerceValue(e.target.value);
359+
},
360+
onFieldInput(e) {
361+
if (!this.useLazyBinding) {
362+
this.value = this.coerceValue(e.target.value);
363+
}
364+
},
349365
getOptionName(value) {
350366
const translationKey = `config.options.${this.property}.${value || "none"}`;
351367
return this.$te(translationKey) ? this.$t(translationKey) : value;

0 commit comments

Comments
 (0)