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

Fix AutocompleteInput suggestions flicker when used inside ReferenceInput #8037

Merged
merged 10 commits into from
Aug 5, 2022

Conversation

fzaninotto
Copy link
Member

Closes #7767

@@ -97,6 +97,7 @@ export const useReferenceInputController = <RecordType extends RaRecord = any>(
},
{
enabled: isGetMatchingEnabled,
keepPreviousData: true,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the main cause of the flicker

packages/ra-ui-materialui/src/input/AutocompleteInput.tsx Outdated Show resolved Hide resolved
@fzaninotto fzaninotto added WIP Work In Progress and removed RFR Ready For Review labels Aug 4, 2022
@davidhenley
Copy link
Contributor

davidhenley commented Aug 9, 2022

FYI We are getting the "The value provided to Autocomplete is invalid." warning again in the console with this on every AutocompleteInput on change.

Screen Shot 2022-08-09 at 11 33 28 AM

@fzaninotto
Copy link
Member Author

@davidhenley II've just tested the simple example in the next branch and got no warning. Can you explain how you got this warning?

@davidhenley
Copy link
Contributor

davidhenley commented Aug 9, 2022

@fzaninotto

I got it when the selected value isn't in the getList call from the data provider that the autocomplete does on load.

It only happens when you select a value that isn't in the first 25 or whatever values.

What's weird is the warning is about the old value and not the newly selected value. This is with the latest release.

So if I have this:

<ReferenceInput source="cityCodeId" reference="city-codes">
  <AutocompleteInput />
</ReferenceInput>

Here are the 2 calls it makes on load of Edit:

/city-codes?fiterinfo...

Screen Shot 2022-08-09 at 2 03 44 PM

/city-codes?ids=11

Screen Shot 2022-08-09 at 2 03 49 PM

Now if I choose the first option I get this error (which is about the previous value) since the option isn't in the available list of options

Screen Shot 2022-08-09 at 2 04 08 PM

This was working fine in 4.2.5 and as soon as we updated I get this on every single AutocompleteInput

@davidhenley
Copy link
Contributor

@fzaninotto updated w pictures and code

@fzaninotto
Copy link
Member Author

This was working fine in 4.2.5 and as soon as we updated I get this on every single AutocompleteInput

How could you update? This change hasn't been released as it's scheduled for react-admin 4.3, due end of this month.

@davidhenley
Copy link
Contributor

Sorry, it wasn't this particular change then, another change in 4.2.6. Thanks.

@fzaninotto
Copy link
Member Author

Then please open a new issue, and include a reproduction case based on the simple example codesandbox.

https://codesandbox.io/s/github/marmelab/react-admin/tree/master/examples/simple

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants