From 231fa46c30b1f2b001f4e6255e7b8ea7ca3a4b4e Mon Sep 17 00:00:00 2001 From: Jordan Jones Date: Mon, 16 Dec 2024 13:31:32 -0800 Subject: [PATCH] fix: reset validity when setting value to undefined #118 --- components/checkbox/demo/api.min.js | 4 ++++ components/checkbox/demo/index.min.js | 4 ++++ components/combobox/demo/api.min.js | 8 ++++++++ components/combobox/demo/index.min.js | 8 ++++++++ components/datepicker/demo/api.min.js | 8 ++++++++ components/datepicker/demo/index.min.js | 8 ++++++++ components/input/demo/api.min.js | 4 ++++ components/input/demo/index.min.js | 4 ++++ components/radio/demo/api.min.js | 4 ++++ components/radio/demo/index.min.js | 4 ++++ packages/form-validation/src/validation.js | 4 ++++ 11 files changed, 60 insertions(+) diff --git a/components/checkbox/demo/api.min.js b/components/checkbox/demo/api.min.js index 87b42eda..9ce5d3dd 100644 --- a/components/checkbox/demo/api.min.js +++ b/components/checkbox/demo/api.min.js @@ -434,6 +434,10 @@ class AuroFormValidation { this.validateType(elem); this.validateAttributes(elem); } + } else if (elem.value === undefined) { + // Reset the validity state if input is programmatically reset + elem.validity = undefined; + elem.isValid = false; } if (this.auroInputElements && this.auroInputElements.length > 0) { diff --git a/components/checkbox/demo/index.min.js b/components/checkbox/demo/index.min.js index 87b42eda..9ce5d3dd 100644 --- a/components/checkbox/demo/index.min.js +++ b/components/checkbox/demo/index.min.js @@ -434,6 +434,10 @@ class AuroFormValidation { this.validateType(elem); this.validateAttributes(elem); } + } else if (elem.value === undefined) { + // Reset the validity state if input is programmatically reset + elem.validity = undefined; + elem.isValid = false; } if (this.auroInputElements && this.auroInputElements.length > 0) { diff --git a/components/combobox/demo/api.min.js b/components/combobox/demo/api.min.js index 0daad875..b551cee1 100644 --- a/components/combobox/demo/api.min.js +++ b/components/combobox/demo/api.min.js @@ -401,6 +401,10 @@ let AuroFormValidation$1 = class AuroFormValidation { this.validateType(elem); this.validateAttributes(elem); } + } else if (elem.value === undefined) { + // Reset the validity state if input is programmatically reset + elem.validity = undefined; + elem.isValid = false; } if (this.auroInputElements && this.auroInputElements.length > 0) { @@ -5263,6 +5267,10 @@ class AuroFormValidation { this.validateType(elem); this.validateAttributes(elem); } + } else if (elem.value === undefined) { + // Reset the validity state if input is programmatically reset + elem.validity = undefined; + elem.isValid = false; } if (this.auroInputElements && this.auroInputElements.length > 0) { diff --git a/components/combobox/demo/index.min.js b/components/combobox/demo/index.min.js index 35fc4bd8..f268a506 100644 --- a/components/combobox/demo/index.min.js +++ b/components/combobox/demo/index.min.js @@ -305,6 +305,10 @@ let AuroFormValidation$1 = class AuroFormValidation { this.validateType(elem); this.validateAttributes(elem); } + } else if (elem.value === undefined) { + // Reset the validity state if input is programmatically reset + elem.validity = undefined; + elem.isValid = false; } if (this.auroInputElements && this.auroInputElements.length > 0) { @@ -5167,6 +5171,10 @@ class AuroFormValidation { this.validateType(elem); this.validateAttributes(elem); } + } else if (elem.value === undefined) { + // Reset the validity state if input is programmatically reset + elem.validity = undefined; + elem.isValid = false; } if (this.auroInputElements && this.auroInputElements.length > 0) { diff --git a/components/datepicker/demo/api.min.js b/components/datepicker/demo/api.min.js index f1fd97e8..7d88d461 100644 --- a/components/datepicker/demo/api.min.js +++ b/components/datepicker/demo/api.min.js @@ -494,6 +494,10 @@ let AuroFormValidation$1 = class AuroFormValidation { this.validateType(elem); this.validateAttributes(elem); } + } else if (elem.value === undefined) { + // Reset the validity state if input is programmatically reset + elem.validity = undefined; + elem.isValid = false; } if (this.auroInputElements && this.auroInputElements.length > 0) { @@ -15442,6 +15446,10 @@ class AuroFormValidation { this.validateType(elem); this.validateAttributes(elem); } + } else if (elem.value === undefined) { + // Reset the validity state if input is programmatically reset + elem.validity = undefined; + elem.isValid = false; } if (this.auroInputElements && this.auroInputElements.length > 0) { diff --git a/components/datepicker/demo/index.min.js b/components/datepicker/demo/index.min.js index 06e2c4a8..1b6ff57c 100644 --- a/components/datepicker/demo/index.min.js +++ b/components/datepicker/demo/index.min.js @@ -242,6 +242,10 @@ let AuroFormValidation$1 = class AuroFormValidation { this.validateType(elem); this.validateAttributes(elem); } + } else if (elem.value === undefined) { + // Reset the validity state if input is programmatically reset + elem.validity = undefined; + elem.isValid = false; } if (this.auroInputElements && this.auroInputElements.length > 0) { @@ -15190,6 +15194,10 @@ class AuroFormValidation { this.validateType(elem); this.validateAttributes(elem); } + } else if (elem.value === undefined) { + // Reset the validity state if input is programmatically reset + elem.validity = undefined; + elem.isValid = false; } if (this.auroInputElements && this.auroInputElements.length > 0) { diff --git a/components/input/demo/api.min.js b/components/input/demo/api.min.js index 67dc8ee3..ebf3dd9c 100644 --- a/components/input/demo/api.min.js +++ b/components/input/demo/api.min.js @@ -2011,6 +2011,10 @@ class AuroFormValidation { this.validateType(elem); this.validateAttributes(elem); } + } else if (elem.value === undefined) { + // Reset the validity state if input is programmatically reset + elem.validity = undefined; + elem.isValid = false; } if (this.auroInputElements && this.auroInputElements.length > 0) { diff --git a/components/input/demo/index.min.js b/components/input/demo/index.min.js index 47cd408d..ee2b32b7 100644 --- a/components/input/demo/index.min.js +++ b/components/input/demo/index.min.js @@ -1957,6 +1957,10 @@ class AuroFormValidation { this.validateType(elem); this.validateAttributes(elem); } + } else if (elem.value === undefined) { + // Reset the validity state if input is programmatically reset + elem.validity = undefined; + elem.isValid = false; } if (this.auroInputElements && this.auroInputElements.length > 0) { diff --git a/components/radio/demo/api.min.js b/components/radio/demo/api.min.js index ab2aa407..b3cbb77d 100644 --- a/components/radio/demo/api.min.js +++ b/components/radio/demo/api.min.js @@ -516,6 +516,10 @@ class AuroFormValidation { this.validateType(elem); this.validateAttributes(elem); } + } else if (elem.value === undefined) { + // Reset the validity state if input is programmatically reset + elem.validity = undefined; + elem.isValid = false; } if (this.auroInputElements && this.auroInputElements.length > 0) { diff --git a/components/radio/demo/index.min.js b/components/radio/demo/index.min.js index 449197fb..da9086a4 100644 --- a/components/radio/demo/index.min.js +++ b/components/radio/demo/index.min.js @@ -499,6 +499,10 @@ class AuroFormValidation { this.validateType(elem); this.validateAttributes(elem); } + } else if (elem.value === undefined) { + // Reset the validity state if input is programmatically reset + elem.validity = undefined; + elem.isValid = false; } if (this.auroInputElements && this.auroInputElements.length > 0) { diff --git a/packages/form-validation/src/validation.js b/packages/form-validation/src/validation.js index 50215b92..b838dfc0 100644 --- a/packages/form-validation/src/validation.js +++ b/packages/form-validation/src/validation.js @@ -144,6 +144,10 @@ export default class AuroFormValidation { this.validateType(elem); this.validateAttributes(elem); } + } else if (elem.value === undefined) { + // Reset the validity state if input is programmatically reset + elem.validity = undefined; + elem.isValid = false; } if (this.auroInputElements && this.auroInputElements.length > 0) {