Skip to content
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

bug: ion-input new v7 errorText displayed right away #26939

Closed
3 tasks done
cyrilletuzi opened this issue Mar 9, 2023 · 5 comments
Closed
3 tasks done

bug: ion-input new v7 errorText displayed right away #26939

cyrilletuzi opened this issue Mar 9, 2023 · 5 comments
Labels
package: core @ionic/core package type: bug a confirmed bug report

Comments

@cyrilletuzi
Copy link

cyrilletuzi commented Mar 9, 2023

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

v7 introduced errorText property to <ion-input>. But if the input has the required attribute, which is one of the most basic and common control, the errorText will be displayed right away when the form is displayed. This is problematic for several reason:

  • it's bad UX (we should not annoy the user right away, only once the user touched the input and moved to another one)
  • it's inconsistent with the visual behavior: on first display, the CSS is normal, and it turns red only if the input is invalid and touched and the user has moved to another input, as expected
  • it ruins all the new simpler <ion-input> behavior introduced in v7, as it forces to add back a <ion-item> with <ion-note slot="error" *ngIf="emailControl.invalid && emailControl.dirty"> (assuming it's still possible, which is not even sure, it doesn't work in v7 in my application anymore, probably because you can't mix the 2 systems)

Expected Behavior

<ion-input> errorText should behave like CSS, ie. be displayed only when the input is invalid and touched and moved away to another input.

Steps to Reproduce

  1. Add a <ion-input type="text" label="text" name="hello" required errorText="Error" [(ngModel)]="hello">

(sorry I tried to do a stackblitz but I couldn't make it work with ionic v7 and I have no more time to create a full github repo)

Code Reproduction URL

No response

Ionic Info

@ionic/angular v7.0.0-rc.1
@angular/* v15.2.2x
node v18.15.0
npm v9.6.0

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Mar 9, 2023
@cyrilletuzi
Copy link
Author

(Another solution would be to introduce a new property, like errorTextTrigger with values like touched, dirty...).

@liamdebeasi liamdebeasi self-assigned this Mar 9, 2023
@liamdebeasi liamdebeasi added package: core @ionic/core package type: bug a confirmed bug report labels Mar 9, 2023
@ionitron-bot ionitron-bot bot removed triage labels Mar 9, 2023
@liamdebeasi
Copy link
Contributor

Thanks for the report. Here is a dev build if you are interested in testing the proposed fix:

npm install @ionic/[email protected]

@liamdebeasi liamdebeasi removed their assignment Mar 9, 2023
@cyrilletuzi
Copy link
Author

I confirm it works with the dev build, thanks!

@liamdebeasi
Copy link
Contributor

Thanks for the issue. This has been resolved via #26940, and a fix will be available in an upcoming release of Ionic Framework.

@ionitron-bot
Copy link

ionitron-bot bot commented Apr 9, 2023

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Apr 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: core @ionic/core package type: bug a confirmed bug report
Projects
None yet
Development

No branches or pull requests

2 participants