-
Notifications
You must be signed in to change notification settings - Fork 77
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
Calcite input validity
, validationMessage
, and willValidate
properties
#7413
Comments
Our team also encountered this issue and ended up having to refactor or add in clunky logic to target the inputs inside of the custom calcite input elements. This would be a great feature to have. |
validity
propertyvalidity
and validationMessage
properties
validity
and validationMessage
propertiesvalidity
, validationMessage
, and willValidate
properties
It looks like support for form-associated components landed in Stencil 4.51 Footnotes |
Safari needs to support However, the recent
Here is a complete demo of the new features: Calcite will transition its form implementation to Let me know if you have any questions or concerns as you start testing the new functionality! |
Thanks for the update @benelan! It looks like a lot of this will be very beneficial to Field Maps. Not sure what's on the roadmap or how transitioning to
Codepen reference implementation
Possible bugsHappy to create issues for any of these.
|
Note that you could get the "valid" attribute in a very old version of calcite, |
With the transition to Lit from Stencil, Calcite is ensuring stability before proceeding with |
Check existing issues
Description
Native
<input>
elements implement the Constraint Validation API. Various attributes indicate which types of values are considered valid and which are invalid (e.g.required
,pattern
,min
,max
, etc…). The<input>
uses avalidity
property (of typeValidityState
) to expose if its value is valid or, if not, the reason why the value is invalid. This property is updated internally everyinput
event. UsefulvalidationMessage
andwillValidate
properties also exist. See API doc for these properties.If Calcite inputs similarly exposed
validity
andwillValidate
properties, it would offload much of the redundant validation logic the consumer currently has to perform in order to figure out which error message to show. Exposing thevalidationMessage
property could also alleviate the need for exhaustive string translations.The API exposes other helpful functionality such as
checkValidity()
,reportValidity()
,setCustomValidity()
, and theinvalid
event -- however, implementing these probably wouldn't get us much until Calcite inputs render their own error messages.Blocked issues: #8126
Acceptance Criteria
validity
property of typeValidityState
that always reflects the validity of the input's current value.validationMessage
property that always reflects the reason for why an input is invalid.willValidate
property that always reflects whether the input should report its validity.Relevant Info
I suspect the implementation could be as simple as passing through the underlying
<input>
element'svalidity
,validationMessage
, andwillValidate
properties. For a more feature-complete implementation, consider converting Calcite inputs to form-associated components once Stencil supports them.1The Field Apps web team is planning a rewrite of the form-editing experience this Fall. This UI includes complex validation rules that could be simplified by offloading some of the more agnostic validation logic to the Calcite input elements.
Which Component
All Calcite inputs.
Example Use Case
Priority impact
p3 - want for upcoming milestone
Calcite package
Esri team
ArcGIS Field Apps
Footnotes
https://github.com/ionic-team/stencil/issues/2284 ↩
The text was updated successfully, but these errors were encountered: