-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
fix(input, textarea): show error state after touch #26940
Conversation
|
:host(.ion-touched.ion-invalid) { | ||
--highlight-color: var(--highlight-color-invalid); | ||
} | ||
|
||
:host(.ion-touched.ion-valid) { | ||
--highlight-color: var(--highlight-color-valid); | ||
} | ||
|
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.
This was duplicate code
// Input Highlight | ||
// ---------------------------------------------------------------- | ||
|
||
:host(.ion-touched.ion-invalid) { | ||
--highlight-color: var(--highlight-color-invalid); | ||
} | ||
|
||
:host(.ion-touched.ion-valid) { | ||
--highlight-color: var(--highlight-color-valid); | ||
} | ||
|
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.
This was duplicate code
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.
Changes look good.
The test templates (e.g. test/bottom-content/index.html) are a little confusing to reason about right now, unless you are aware of the extra classes that need to be appended to the host to make the error slot visible and/or the styling. Should we add a minimal implementation here with a button that adds the required classes to help with manually testing?
Good catch! I updated those templates so |
Pull request checklist
Please check if your PR fulfills the following requirements:
ionic-docs
repo, in a separate PR. See the contributing guide for details.npm run build
) was run locally and any changes were pushednpm run lint
) has passed locally and any fixes were made for failuresPull request type
Please check the type of change your PR introduces:
What is the current behavior?
Issue URL: resolves #26939, resolves #21643
There are a couple issues with the form validation highlighting:
Form validation highlighting is used to indicate that the user did something right/wrong, so having these states always show can be confusing.
What is the new behavior?
I updated the behavior as per the following table:
Reasoning for invalid state changes: An invalid state indicates the user entered malformed/incorrect data. As a result, having the invalid state show before the user has even interacted with the input can be confusing for the user. We show the input regardless of focus state once it has been touched. This is because users may need to correct data in order to submit a form. Showing the invalid highlight on both focus and blur lets users quickly identify which form controls need fixing.
Reasoning for the valid changes: A valid state indicates that the user entered correct data. As a result, we should give them that positive feedback as soon as their data is valid. We also show the valid state regardless of touched state because some forms may pre-populate data. Users may not necessarily want to change that pre-populated data if it is valid. Additionally, the user does not need to always know that an input is valid which is why we only show it on focus. This behavior also aligns with the behavior found in Ionic 6.
Does this introduce a breaking change?
Other information
Dev build: 7.0.0-dev.11678373650.1975657a