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

FloatLabel: Incorrect position when using browser autofill #2921

Closed
andreiGadjylaJS opened this issue May 24, 2022 · 5 comments · Fixed by #2922
Closed

FloatLabel: Incorrect position when using browser autofill #2921

andreiGadjylaJS opened this issue May 24, 2022 · 5 comments · Fixed by #2922
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@andreiGadjylaJS
Copy link

Describe the bug

Good afternoon. When you click on the label field, it works correctly. But when choosing a value from the drop-down list provided by the browser (previously entered value in the field), the label moves to the top, when choosing a value from previously entered values, the label remains in the wrong place, but when changes are made to the field, the label returns to its place.

Reproducer

https://codesandbox.io/s/naughty-poincare-5sxfrq?file=/src/demo/InputTextDemo.tsx

PrimeReact version

8.1.0

React version

18.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

Chrome 101.0.4951.67

Steps to reproduce the behavior

  1. Focus on the InputText field
  2. Select a value from previously entered values (the list is provided by the browser)
  3. Select the previously entered value

Expected behavior

When working with the InputText field, its label was placed at the place specified for it, and did not change position when entering data into this field

@andreiGadjylaJS andreiGadjylaJS added the Type: Bug Issue contains a defect related to a specific component. label May 24, 2022
@andreiGadjylaJS
Copy link
Author

image

@andreiGadjylaJS
Copy link
Author

image

@melloware melloware changed the title Component: InputText FloatLabel: Incorrect position when using browser autofill May 24, 2022
@melloware
Copy link
Member

The problem is this:

.p-float-label input:-webkit-autofill ~ label {
    top: -20px;
    font-size: 12px;
}

For some reason when using webkit-autofill its adding -20px to top instead of the normal -0.75rem when NOT using autofill?

melloware added a commit to melloware/primereact that referenced this issue May 24, 2022
@melloware melloware self-assigned this May 24, 2022
@melloware melloware added this to the 8.2.0 milestone May 24, 2022
@melloware
Copy link
Member

As a workaronud just add this CSS to your custom CSS of your project:

.p-float-label input:-webkit-autofill ~ label {
  top: -0.75rem;
  font-size: 12px;
}

@melloware melloware added the Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team label May 24, 2022
@andreiGadjylaJS
Copy link
Author

Thanks.

@mertsincan mertsincan removed 👍 confirmed Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team labels Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants