From c80f9b723614caa60f736e8b5247730ff67c5d2c Mon Sep 17 00:00:00 2001 From: Jonas Metzener Date: Wed, 4 Sep 2024 15:05:31 +0200 Subject: [PATCH] fix(number-separator): display zero values correctly --- .../addon/components/cf-field/input/number-separator.js | 2 +- .../components/cf-field/input/number-separator-test.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/form/addon/components/cf-field/input/number-separator.js b/packages/form/addon/components/cf-field/input/number-separator.js index 8c7f009a5..4b3b0d95a 100644 --- a/packages/form/addon/components/cf-field/input/number-separator.js +++ b/packages/form/addon/components/cf-field/input/number-separator.js @@ -11,7 +11,7 @@ export default class CfFieldInputNumberSeparatorComponent extends Component { } get displayValue() { - if (!this.args.field.value) { + if (isNaN(parseFloat(this.args.field.value))) { return ""; } diff --git a/packages/form/tests/integration/components/cf-field/input/number-separator-test.js b/packages/form/tests/integration/components/cf-field/input/number-separator-test.js index e26789eaf..daae2395d 100644 --- a/packages/form/tests/integration/components/cf-field/input/number-separator-test.js +++ b/packages/form/tests/integration/components/cf-field/input/number-separator-test.js @@ -34,6 +34,9 @@ module( assert.strictEqual(this.field.value, 1234); assert.dom("input").hasValue("1’234"); + + await fillIn("input", "0"); + assert.dom("input").hasValue("0"); }); test("it converts floats to formatted strings and saves them properly", async function (assert) { @@ -47,6 +50,9 @@ module( assert.strictEqual(this.field.value, 1234.123); assert.dom("input").hasValue("1’234.123"); + + await fillIn("input", "0"); + assert.dom("input").hasValue("0"); }); test("it displays calculated floats properly", async function (assert) {