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

InputText/InputTextArea: .p-filled class/isFilled bool not resetting after setValue("") #4351

Closed
Syuks opened this issue May 8, 2023 · 1 comment · Fixed by #4354
Closed
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@Syuks
Copy link

Syuks commented May 8, 2023

Describe the bug

When trying to reset an InputText by setting its value to an empty string, the "p-filled" class does not get cleared until the next render.

This is clearly noticeable when using an InputText with a FloatLabel. After setting the input's value to "", the float label stays up and doesn't come down until a new render happens. If more than 1 input were resetted at the same time withing the same function, all float labels would stay up. Also if I remove the class programmatically when resetting the value, the float label breaks because isFilled bool gets desynced with the class.

Apart from just feeling like unintended behavior, this bug leaves the developer with no proper way of resetting an InputText with a float label and the class can't be used as a safe way of adding further functionality or styles dependent on it.

If it is of any use, this bug is also present in v8, with react 17 and using Vite.

Reproducer

https://codesandbox.io/s/interesting-banach-8i36zg?file=/src/demo/FloatLabelDemo.js

PrimeReact version

9.3.1

React version

18.x

Language

ALL

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

  1. Create a controlled InputText.
  2. Create a button that sets the value of the InputText to an empty string on click.
  3. Write anything in the InputText.
  4. Press the button.
  5. See how the "p-filled" class is still present in the InputText.

Add a Float Label to the InputText if visual feedback is needed for testing.

Expected behavior

I expect the "p-filled" class of the InputText to be cleared in the same render I set the value of the input to an empty string (reset the InputText).

@Syuks Syuks added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label May 8, 2023
melloware added a commit to melloware/primereact that referenced this issue May 8, 2023
@melloware melloware self-assigned this May 8, 2023
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels May 8, 2023
@melloware melloware added this to the 9.4.0 milestone May 8, 2023
melloware added a commit to melloware/primereact that referenced this issue May 8, 2023
melloware added a commit to melloware/primereact that referenced this issue May 8, 2023
@melloware
Copy link
Member

Looks like InputTextArea needed the exact same fix as well.

@melloware melloware changed the title InputText: .p-filled class/isFilled bool not resetting after setValue("") InputText/InputTextArea: .p-filled class/isFilled bool not resetting after setValue("") May 10, 2023
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.

2 participants