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

AutoComplete: Reusing references for suggestions prop bug #3659

Closed
niissaao opened this issue Nov 16, 2022 · 2 comments · Fixed by #3675
Closed

AutoComplete: Reusing references for suggestions prop bug #3659

niissaao opened this issue Nov 16, 2022 · 2 comments · Fixed by #3675
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@niissaao
Copy link

Describe the bug

Using AutoComplete component when I want to select the same value twice in a row there is a case when it doesn't work.
The case is when passing a dynamically build array to the suggestion property it keeps its references between renders.
In the provided CodeSandbox project when we first select the initialValue an event is fired but when it is selected again the event is not registered.
The same erroneous behavior is not applicable to inlineLabel due to the fact that its reference is recalculated on every render.

Also, for the suggestions list to appear we have to copy the array so it has a new reference, for it to appear.

Reproducer

https://codesandbox.io/s/primereact-autocomplete-suggestion-reference-bug-zzso64?file=/src/index.js

PrimeReact version

8.3.0

React version

18.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

Firefox/ Chrome

Steps to reproduce the behavior

  1. Go to https://codesandbox.io/s/primereact-autocomplete-suggestion-reference-bug-zzso64?file=/src/index.js
  2. Expand the AutoComplete component
  3. Select inlineLabel value
  4. Select inlineLabel value again
  • notice that a new "event" has been created twice
  1. Select initialValue value
  • notice that a new "event" has been created
  1. Select initialValue value again
  • notice that no new "event" has been created
  1. Type "Demo" on the input field
  • notice that 4 events were created (one for each keypress)
  1. Select Demo value
  • notice that a new "event" has been created
  1. Select Demo value again
  • notice that no new "event" has been created

Expected behavior

On steps 6 and 9 an "event" should be created.

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

@niissaao have you researched a possible fix?

@melloware melloware added the Type: Bug Issue contains a defect related to a specific component. label Nov 18, 2022
@melloware
Copy link
Member

OK it's because of this fix: #2176

@melloware melloware removed the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Nov 18, 2022
@melloware melloware self-assigned this Nov 18, 2022
@melloware melloware added this to the 8.7.3 milestone Nov 18, 2022
melloware added a commit to melloware/primereact that referenced this issue Nov 18, 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.

2 participants