You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug: FloatLabel inside Accordion misbehaves when dynamically adding/removing items
Description
When using the FloatLabel component inside an Accordion with dynamically added/removed items (using useFieldArray from react-hook-form), the FloatLabel does not behave correctly. Specifically:
When a new item is added, the FloatLabel for the previous items immediately don't "float" while the input have value.
The issue occurs without-with needing to collapse/expand the Accordion tabs.
Expected Behavior
The FloatLabel should only "float" when the corresponding input field is focused or contains content.
Adding or removing items dynamically should not affect the FloatLabel state of other items.
Actual Behavior
The FloatLabel for previous items immediately don't "float" when a new item is added, while the input have value.
The issue occurs immediately after adding a new item, without requiring any interaction with the Accordion.
Steps to Reproduce
Use the Accordion component with dynamically added/removed items.
Place a FloatLabel and InputText inside each AccordionTab.
Add a new item dynamically (e.g., using a button to append to the fields array).
Observe that the FloatLabel for previous items misbehaves.
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
Mar 7, 2025
melloware
changed the title
Bug: FloatLabel inside Accordion misbehaves when dynamically adding/removing items
FloatLabel: inside Accordion misbehaves when dynamically adding/removing items
Mar 7, 2025
Describe the bug
Bug:
FloatLabel
insideAccordion
misbehaves when dynamically adding/removing itemsDescription
When using the
FloatLabel
component inside anAccordion
with dynamically added/removed items (usinguseFieldArray
fromreact-hook-form
), theFloatLabel
does not behave correctly. Specifically:FloatLabel
for the previous items immediately don't "float" while the input have value.Accordion
tabs.Expected Behavior
FloatLabel
should only "float" when the corresponding input field is focused or contains content.FloatLabel
state of other items.Actual Behavior
FloatLabel
for previous items immediately don't "float" when a new item is added, while the input have value.Accordion
.Steps to Reproduce
Accordion
component with dynamically added/removed items.FloatLabel
andInputText
inside eachAccordionTab
.fields
array).FloatLabel
for previous items misbehaves.Minimal Reproducible Example
Here’s a minimal example to reproduce the issue:
Environment
Additional Information
FloatLabel
is used outside theAccordion
.Accordion
orAccordionTab
usingkey
props does not resolve the issue.Suggested Fix
The issue might be related to how the
Accordion
component manages its internal state when dynamic content is added. A potential fix could involve:FloatLabel
component properly re-initializes when its parentAccordionTab
is re-rendered.FloatLabel
to re-evaluate its state when dynamic content is added.Reproducer
https://stackblitz.com/edit/vitejs-vite-mzkmrc8x
System Information
Steps to reproduce the behavior
Steps to Reproduce the Behavior
Set up a form with dynamic fields:
react-hook-form
withuseFieldArray
to manage an array of questions.AccordionTab
component from PrimeReact.Add
FloatLabel
andInputText
to eachAccordionTab
:AccordionTab
, include aFloatLabel
wrapping anInputText
component.Add a button to append new questions dynamically:
fields
array using theappend
method fromuseFieldArray
.Observe the behavior:
FloatLabel
for previous accordion's questions don't "float" while their input fields have values.Expected behavior
FloatLabel
should only "float" when the corresponding input field is focused or contains content.FloatLabel
for previous questions don't "float" without any interaction with the input fields.The text was updated successfully, but these errors were encountered: