From 1b647d1ec2eb977176c23a875eb52c712ef48f9d Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 8 Jan 2024 14:32:25 -0700 Subject: [PATCH] Api: Fix Et2Number did not respect min/max --- api/js/etemplate/Et2Textbox/Et2Number.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/js/etemplate/Et2Textbox/Et2Number.ts b/api/js/etemplate/Et2Textbox/Et2Number.ts index ab02b8df9e..af63ff2f6f 100644 --- a/api/js/etemplate/Et2Textbox/Et2Number.ts +++ b/api/js/etemplate/Et2Textbox/Et2Number.ts @@ -185,7 +185,9 @@ export class Et2Number extends Et2Textbox private handleScroll(e) { const old_value = this.value; - this.value = "" + (this.valueAsNumber + e.detail * (parseFloat(this.step) || 1)); + const min = parseFloat(this.min ?? Number.MIN_SAFE_INTEGER); + const max = parseFloat(this.max ?? Number.MAX_SAFE_INTEGER); + this.value = "" + Math.min(Math.max(this.valueAsNumber + e.detail * (parseFloat(this.step) || 1), min), max); this.dispatchEvent(new CustomEvent("sl-change", {bubbles: true})); this.requestUpdate("value", old_value); }