question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: slot error not working properly in ion-item in some cases

See original GitHub issue

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x

Current Behavior

The new slot “error” does not work when using an ion-input in the same ion-icon. The slot “helper” seems to work normally.

<ion-item>
     <ion-label [position]="'fixed'">Label</ion-label>
     <ion-input></ion-input>
     <ion-note slot="error">Test</ion-note
</ion-item>

In this example, the “Test” text is not visible at all. When I use an ion-label instead of an ion-note for the error, it shows the error element but it only has 50% width of the full ion-item.

Expected Behavior

Items with the error slot should show up as expected.

Steps to Reproduce

See above.

Code Reproduction URL

No response

Ionic Info

Ionic:

Ionic CLI : 6.18.1 (/usr/local/lib/node_modules/@ionic/cli) Ionic Framework : @ionic/angular 6.0.1 @angular-devkit/build-angular : 12.2.12 @angular-devkit/schematics : 12.2.12 @angular/cli : 12.2.12 @ionic/angular-toolkit : 5.0.3

Capacitor:

Capacitor CLI : 3.3.3 @capacitor/android : not installed @capacitor/core : 3.3.3 @capacitor/ios : not installed

Utility:

cordova-res (update available: 0.15.4) : 0.15.1 native-run : 1.5.0

System:

NodeJS : v17.0.1 (/usr/local/Cellar/node/17.0.1/bin/node) npm : 8.1.0 OS : macOS Monterey

Additional Information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
sean-perkinscommented, Jan 14, 2022

@vildhjarta8 I’m seeing the same issue as you. It’s a Safari issue with style priority (can see with web browser).

I’ll look into the fix. I may need to do some repurposing/splitting of this issue, because we have a few different conversations around the slot="error" happening and I don’t want to miss out on those details.

2reactions
sean-perkinscommented, Dec 20, 2021

Hello @andreas-aeschlimann, thanks for the issue!

This may just be poor documentation on our part.

The error slot with ion-item is intended to be used with a form and currently our only direct integration is with Angular Forms. When using form controls, Ionic will map the ng-invalid class to ion-invalid on the item. This class is the missing piece to make the error slot visible.

If you update your example to this:

<ion-item class="ion-invalid">
  <ion-label position="fixed">Label</ion-label>
  <ion-input></ion-input>
  <ion-note slot="error">Test</ion-note>
</ion-item>

You will see the error slot always.

Let me know if this resolves the issue for you. I don’t believe this is a bug, as we don’t want to display the error contents if the form control isn’t in an error state.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionic 6 Angular slot="error" doesn't work with ion-checkbox ...
In general seems its supported only for input fields. Here its the detailed answer from Ionic team ...
Read more >
Ionic v6 beta release - Mastering Ionic
Quite a lot as it happens - new UI components (and some that are deprecated ... value="colours"> <ion-item slot="header"> <ion-label>Primary ...
Read more >
You searched for Typescript - Ionic Blog
This allows teams to iterate quickly and fix critical issues by pushing ... There are a few bug fixes in this release as...
Read more >
ion-input: Custom Input Value Type Styling and CSS Properties
ion-input is a wrapper to the HTML input element, with custom value type styling ... The error slot will not be displayed unless...
Read more >
Blog - Crojach Software
Let's create a simple Ionic app and add in some HTML and Typescript ... It worked well enough to fix the problem but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found