ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
51.14k stars 13.5k forks source link

bug: input inside of item gets truncated with long label on smaller viewports #24790

Open infacto opened 2 years ago

infacto commented 2 years ago

Prerequisites

Ionic Framework Version

Current Behavior

The ion-label displaces the ion-input value. Text wrap makes no difference and does not matter.

demo

Expected Behavior

The ion-input (value) must be dominant. Both elements should always be displayed.

Steps to Reproduce

<ion-item>
  <ion-label>This is my number input label</ion-label>
  <ion-input type="number" class="ion-text-right" value="42"></ion-input>
</ion-item>

<ion-item>
  <ion-label class="ion-text-wrap">This is my number input label</ion-label>
  <ion-input type="number" class="ion-text-right" value="42"></ion-input>
</ion-item>

See CodePen.

Ionic Info

No Ionic workspace. Therefore no ionic info CLI possible. It's Angular 12.2.14 with Ionic 5.9.2.

Additional Information

I selected Ionic 5 but I'm using the latest Ionic version in CodePen.

DwieDima commented 2 years ago

try this

<ion-item>
  <ion-label class="ion-text-wrap">This is my number input label</ion-label>
  <ion-input slot="end" type="number" class="ion-text-right" value="42"></ion-input>
</ion-item>
liamdebeasi commented 2 years ago

Thanks for the issue. Can you provide some information surrounding the desire to have ion-item elements be that small? Our components are designed for mobile + tablet device screens with ion-item intended to take up the entire width of the screen. This particular behavior only happens around ~280px in width, which is smaller than many device screens that we support.

infacto commented 2 years ago

@DwieDima Thanks, I forgot. Slot "end" prevents the value from being hidden. But take a look to the demo. The label and end slots are both flex and share space 50/50%. Which results in unused / weird space. Label cut off or wrapped for no reason apparent to the user. I already tried some css hacks. But found nothing satisfying. Maybe because native input can't have inline width. I just wonder, why it works without setting slot. Maybe I have to invest more time. Or I redesign the inputs. e.g. using appearance with floating labels. Or change flex ratio. Anyway, slot end is not the solution. The issue here can still occur. demo

@liamdebeasi I also test screens down to a minimum of 320 pixels. This is just to demonstrate the issue and to record a small gif. In my app it happens on bigger screen sizes around mobile 320-375px. See the updated demo. demo Using icons and a word or two more increases issue. Using slot end adds weird spaces due to flex, ... The value should be dominant. This the most important element in an input item. But the label should also use the full remaining space and can optionally wrap.

JulienLecoq commented 2 years ago

@infacto I have the same issue than you with the label that doesn't take the full remaining space. I had to write my own component to "correct" this issue :/

JuliaMikov commented 10 months ago

@infacto @JulienLecoq Had the same issue today. That in the global style helped:

.label-text.sc-ion-input-md, .sc-ion-input-md-s>[slot=label] {
  overflow: visible;
}