From 5be31ead6cb113fdf766a777a05c2e46735723ec Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 12 Nov 2024 13:21:22 -0700 Subject: [PATCH] Api: Fix Et2Number could not display empty value (""), gave 0 instead. --- api/js/etemplate/Et2Textbox/Et2Number.ts | 2 +- api/js/etemplate/Et2Textbox/test/Et2Number.test.ts | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/api/js/etemplate/Et2Textbox/Et2Number.ts b/api/js/etemplate/Et2Textbox/Et2Number.ts index 90417bad6e..107b8efe28 100644 --- a/api/js/etemplate/Et2Textbox/Et2Number.ts +++ b/api/js/etemplate/Et2Textbox/Et2Number.ts @@ -236,7 +236,7 @@ export class Et2Number extends Et2Textbox val = parseFloat(val); } } - if(isNaN(val)) + if(val == "" || isNaN(val)) { super.value = val; this.requestUpdate("value", old); diff --git a/api/js/etemplate/Et2Textbox/test/Et2Number.test.ts b/api/js/etemplate/Et2Textbox/test/Et2Number.test.ts index 7f09b6f4de..fafd967815 100644 --- a/api/js/etemplate/Et2Textbox/test/Et2Number.test.ts +++ b/api/js/etemplate/Et2Textbox/test/Et2Number.test.ts @@ -63,7 +63,13 @@ describe("Number widget", () => element.precision = 0; element.value = "1,234"; assert.equal(element.value, "1", "Wrong number of decimals (, separator)"); - }) + }); + + it("handles blank ('')", () => + { + element.value = ""; + assert.equal(element.value, ""); + }); it("Min limit", () => {