-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add manual validation mode #8097
Changes from all commits
b93bb89
9dc38a9
6d3e615
38b264d
c7927ca
fa535ed
b300ab7
f3ae458
425ccdd
9363511
edb0167
882f110
7bb5d6e
f16801e
b69082b
0865fcb
65e061b
fce941a
ebaec50
a6a051a
74755df
6653f3d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -479,7 +479,7 @@ export const DatePickerMixin = (subclass) => | |
// Do not validate when focusout is caused by document | ||
// losing focus, which happens on browser tab switch. | ||
if (document.hasFocus()) { | ||
this.validate(); | ||
this._requestValidation(); | ||
} | ||
} | ||
} | ||
|
@@ -624,13 +624,8 @@ export const DatePickerMixin = (subclass) => | |
!this._selectedDate || dateAllowed(this._selectedDate, this._minDate, this._maxDate, this.isDateDisabled); | ||
|
||
let inputValidity = true; | ||
if (this.inputElement) { | ||
if (this.inputElement.checkValidity) { | ||
inputValidity = this.inputElement.checkValidity(); | ||
} else if (this.inputElement.validate) { | ||
// Iron-form-elements have the validate API | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: We don't support iron form elements anymore. |
||
inputValidity = this.inputElement.validate(); | ||
} | ||
if (this.inputElement && this.inputElement.checkValidity) { | ||
inputValidity = this.inputElement.checkValidity(); | ||
} | ||
|
||
return inputValid && isDateValid && inputValidity; | ||
|
@@ -717,10 +712,10 @@ export const DatePickerMixin = (subclass) => | |
const unparsableValue = this.__unparsableValue; | ||
|
||
if (this.__committedValue !== this.value) { | ||
this.validate(); | ||
this._requestValidation(); | ||
this.dispatchEvent(new CustomEvent('change', { bubbles: true })); | ||
} else if (this.__committedUnparsableValue !== unparsableValue) { | ||
this.validate(); | ||
this._requestValidation(); | ||
this.dispatchEvent(new CustomEvent('unparsable-change')); | ||
} | ||
|
||
|
@@ -849,7 +844,7 @@ export const DatePickerMixin = (subclass) => | |
|
||
if (oldValue !== undefined) { | ||
// Validate only if `value` changes after initialization. | ||
this.validate(); | ||
this._requestValidation(); | ||
} | ||
} | ||
} else { | ||
|
@@ -1015,7 +1010,7 @@ export const DatePickerMixin = (subclass) => | |
// Needed in case the value was not changed: open and close dropdown, | ||
// especially on outside click. On Esc key press, do not validate. | ||
if (!this.value && !this._keyboardActive) { | ||
this.validate(); | ||
this._requestValidation(); | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,19 @@ export declare class ValidateMixinClass { | |
*/ | ||
invalid: boolean; | ||
|
||
/** | ||
* Set to true to enable manual validation mode. This mode disables automatic | ||
* constraint validation, allowing you to control the validation process yourself. | ||
* You can still trigger constraint validation manually with the `validate()` method | ||
* or use `checkValidity()` to assess the component's validity without affecting | ||
* the invalid state. In manual validation mode, you can also manipulate | ||
* the `invalid` property directly through your application logic without conflicts | ||
* with the component's internal validation. | ||
* | ||
* @attr {boolean} manual-validation | ||
*/ | ||
manualValidation: boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
/** | ||
* Specifies that the user must fill in a value. | ||
*/ | ||
|
@@ -30,4 +43,6 @@ export declare class ValidateMixinClass { | |
* Returns true if the field value satisfies all constraints (if any). | ||
*/ | ||
checkValidity(): boolean; | ||
|
||
protected _requestValidation(): void; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: We don't support iron form elements anymore.