primefaces / primereact

The Most Complete React UI Component Library
https://primereact.org
MIT License
7.01k stars 1.06k forks source link

FloatLabel: The label appears outside the box #6450

Closed CosmeValera closed 7 months ago

CosmeValera commented 7 months ago

Describe the bug

I have the latest Prime React dependency installed, I'm using the new component FloatLabel, but the placeholder is appeearing outside the box.

Images:

image image

Code:

image FloatLabel docu

The error:

image

Reproducer

No response

PrimeReact version

10.6.3

React version

18.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

Chrome

Steps to reproduce the behavior

Use the code as put in the documentation and it won't work

Expected behavior

https://primereact.org/floatlabel/

Rekl0w commented 7 months ago

I guess #6440 will solve this problem

CosmeValera commented 7 months ago

I just realised it was another css file that was colliding with the styles of FloatLabel.

In this case I had this: image

Which was making the span.float-label be centered, but it has no effect on the label, thus creating that strange effect: image With inspector image

I guess that using css files, instead of the theme will cause this type of problems, so it is not guaranteed for bugs like this not to appear when people use custom css like in my case.

Anyway, I've been investigating, and I noticed that the problem happens because both the span (container) and the label have position: relative, therefore label does not depend on the position of span, but on the position of the outer container. This could be fixed making the span that contains the input and the label have position: absolute.

I'm not sure if this behaviour is considered a feature or a bug.