ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

fix(input): do not float label because of slotted items

Open ErikOnBike opened this issue 1 year ago • 1 comments

Issue number: resolves #28665


What is the current behavior?

The input label is floating if an element is slotted. This is especially annoying if a password toggle is present, since it will start floating the label (even when no input is available).

What is the new behavior?

A label will only float (if specified and) if it has a value or received focus.

Does this introduce a breaking change?

  • [ ] Yes
  • [X] No

Other information

Screenshot before: image

Screenshot after: image

This issue also seems to fix issue #29449

ErikOnBike avatar Oct 18 '24 12:10 ErikOnBike

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ionic-framework ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 20, 2024 0:24am

vercel[bot] avatar Oct 18 '24 12:10 vercel[bot]

Changed the visual removal of slotted items to use 'visibility: hidden' to prevent changing the input component's size where 'display: none' could change the size.

ErikOnBike avatar Oct 20 '24 12:10 ErikOnBike

@tanner-reits any news? when will it be merged?

drolpi avatar Nov 05 '24 14:11 drolpi

Hey @ErikOnBike

Thanks for taking a stab at this! Unfortunately, hiding the slotted content until focus doesn't match the designs for Material Design (see demo here). We have a task to look into this internally, but I'm not sure when we'll be able to do so if you want to try to match that behavior.

tanner-reits avatar Nov 05 '24 16:11 tanner-reits

Hey @ErikOnBike

Thanks for taking a stab at this! Unfortunately, hiding the slotted content until focus doesn't match the designs for Material Design (see demo here). We have a task to look into this internally, but I'm not sure when we'll be able to do so if you want to try to match that behavior.

Hi @tanner-reits,

You're completely right. I think I mixed up two issues and tried to solve both in one go. (Not very sensible ;-) Although I now see why that might be the case. If the slotted elements remain visible, the label will overlap with the slotted (start) element. The label is placed in a wrapper before the input. It can't know the size of the slotted items and therefore will be left aligned, overlapping the slotted element. This is more tricky to handle than just prevent it from floating when no input is available.

ErikOnBike avatar Nov 05 '24 18:11 ErikOnBike