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

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ErikOnBike
Copy link

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
  • No

Other information

Screenshot before:
image

Screenshot after:
image

This issue also seems to fix issue #29449

@ErikOnBike ErikOnBike requested a review from a team as a code owner October 18, 2024 12:33
Copy link

vercel bot commented Oct 18, 2024

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

@github-actions github-actions bot added the package: core @ionic/core package label Oct 18, 2024
@ErikOnBike ErikOnBike changed the title Fix #28665: do not float label because of slotted items fix(input): do not float label because of slotted items Oct 18, 2024
@ErikOnBike
Copy link
Author

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.

@drolpi
Copy link

drolpi commented Nov 5, 2024

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

@tanner-reits
Copy link
Member

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.

@ErikOnBike
Copy link
Author

ErikOnBike commented Nov 5, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: input floating label is always floating when using start/end slots
3 participants