From eeb35b102bdca4824f174a41fbc2a6d057ea4f99 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 26 Oct 2024 00:22:52 -0400 Subject: [PATCH 1/5] Fixed an issue with 0 string float label What was corrected in #1212 only handled the input being of type "number" but having the string "0" also caused the label issue. This PR fixes that. --- packages/stencil-library/src/components/dnn-input/dnn-input.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stencil-library/src/components/dnn-input/dnn-input.tsx b/packages/stencil-library/src/components/dnn-input/dnn-input.tsx index 56dcce82..304241e8 100644 --- a/packages/stencil-library/src/components/dnn-input/dnn-input.tsx +++ b/packages/stencil-library/src/components/dnn-input/dnn-input.tsx @@ -184,7 +184,7 @@ export class DnnInput { return false; } - if (this.type === "number" && this.value === 0){ + if (this.value === 0){ return false; } From 6c9a762dc5017477b83b13325b6ac02d329db217 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 26 Oct 2024 00:25:31 -0400 Subject: [PATCH 2/5] Use coercion operation instead of hardly type === --- packages/stencil-library/src/components/dnn-input/dnn-input.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stencil-library/src/components/dnn-input/dnn-input.tsx b/packages/stencil-library/src/components/dnn-input/dnn-input.tsx index 304241e8..eba9cf1e 100644 --- a/packages/stencil-library/src/components/dnn-input/dnn-input.tsx +++ b/packages/stencil-library/src/components/dnn-input/dnn-input.tsx @@ -184,7 +184,7 @@ export class DnnInput { return false; } - if (this.value === 0){ + if (this.value == 0){ return false; } From 4eec43596c5828f36877c306e909b91420620ec1 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 26 Oct 2024 00:54:48 -0400 Subject: [PATCH 3/5] Fixed an issue where label would not float with empty string Another followup on #1212 --- packages/stencil-library/src/components/dnn-input/dnn-input.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stencil-library/src/components/dnn-input/dnn-input.tsx b/packages/stencil-library/src/components/dnn-input/dnn-input.tsx index eba9cf1e..ac462c5c 100644 --- a/packages/stencil-library/src/components/dnn-input/dnn-input.tsx +++ b/packages/stencil-library/src/components/dnn-input/dnn-input.tsx @@ -184,7 +184,7 @@ export class DnnInput { return false; } - if (this.value == 0){ + if (this.value == 0 || this.value !== ""){ return false; } From b566c1c26606594f926c77217f37748540842dd0 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 26 Oct 2024 00:57:52 -0400 Subject: [PATCH 4/5] Another correction --- packages/stencil-library/src/components/dnn-input/dnn-input.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stencil-library/src/components/dnn-input/dnn-input.tsx b/packages/stencil-library/src/components/dnn-input/dnn-input.tsx index ac462c5c..8d34860a 100644 --- a/packages/stencil-library/src/components/dnn-input/dnn-input.tsx +++ b/packages/stencil-library/src/components/dnn-input/dnn-input.tsx @@ -184,7 +184,7 @@ export class DnnInput { return false; } - if (this.value == 0 || this.value !== ""){ + if (this.value === 0 || this.value === "0") { return false; } From c5e6b92c793cf5eab81947a9effa7ae164ea54cf Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 26 Oct 2024 01:24:13 -0400 Subject: [PATCH 5/5] Also handle NaN for label Still about #1212 one edge case is the number technically being a "Number" but it's value being NaN instead of undefined. --- .../stencil-library/src/components/dnn-input/dnn-input.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/stencil-library/src/components/dnn-input/dnn-input.tsx b/packages/stencil-library/src/components/dnn-input/dnn-input.tsx index 8d34860a..88ec28a1 100644 --- a/packages/stencil-library/src/components/dnn-input/dnn-input.tsx +++ b/packages/stencil-library/src/components/dnn-input/dnn-input.tsx @@ -172,6 +172,10 @@ export class DnnInput { } private shouldLabelFloat(): boolean { + if (this.type === "number" && isNaN(this.value as number)) { + return true; + } + if (this.focused) { return false; }