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

Dropdown: Not correctly refreshed when using dynamic fields #3456

Closed
Makistos opened this issue Oct 10, 2022 · 3 comments
Closed

Dropdown: Not correctly refreshed when using dynamic fields #3456

Makistos opened this issue Oct 10, 2022 · 3 comments
Labels
Resolution: By Design The behavior in the issue is by design and the component exhibits the expected behavior

Comments

@Makistos
Copy link

Describe the bug

When creating dropdown components dynamically and then removing some, the values shown in the dropdown are incorrectly shown. They are not updated so even though the values in memory are correct they show the value that was in the location of the removed dropdown.

Reproducer

https://codesandbox.io/s/dropdown-fix-forked-om0ets?file=/src/Form.jsx

PrimeReact version

8.6.1

React version

18.x

Language

ALL

Build / Runtime

Create React App (CRA)

Browser(s)

Chrome 106

Steps to reproduce the behavior

  1. Click the add button next to the second dropdown field.
  2. Click remove next to the second dropdown field.
  3. Notice that second dropdown field still shows "Heinlein" rather than "Clarke" even though the debug print below shows it should be "Clarke".

Expected behavior

Second dropdown should show the value "Clarke".

@Makistos Makistos added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Oct 10, 2022
@melloware
Copy link
Member

To me this looks like a React Hook Form issue as manipulating the list without useState is never telling the DropDown to re-render itself which is the "React" way of doing it. I would ask on the React Hook Form forums or GitHub how to do what you want to do.

@melloware melloware added Resolution: By Design The behavior in the issue is by design and the component exhibits the expected behavior and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Oct 10, 2022
@Makistos
Copy link
Author

Makistos commented Oct 10, 2022

I have, response was to make sure key is properly set for each control which they should.

PR says they support RHF but requires the use of controlled controls. So as I understand it this should work like this.

@melloware
Copy link
Member

I just fixed your sandbox. You were using the wrong key

https://codesandbox.io/s/dropdown-fix-forked-e9np1v?file=/src/Form.jsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: By Design The behavior in the issue is by design and the component exhibits the expected behavior
Projects
None yet
Development

No branches or pull requests

2 participants