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

ReferenceInput does not show loader while possible values and reference record are loading #5805

Closed
anjeylink opened this issue Jan 21, 2021 · 1 comment

Comments

@anjeylink
Copy link

What you were expecting:
When using ReferenceInput expect to get LinearProgress instead of empty input (SelectInput or any other valid children) while data is loading.
I manually set delay in dataProvider to 3 seconds, but loader wasn't shown.

What happened instead:
ReferenceInput renders children like data was loaded, but in reality it's still loading.

Steps to reproduce:
Add ReferenceInput in create/edit form. Simulate delay in data provider more than 1 sec.

<ReferenceInput reference="reference" source="source">
    <SelectInput optionText="name" />
</ReferenceInput>

Possible solution
I think problem is in "useReferenceInputController" when it generates "dataStatus.waiting", because finalData is always empty object and "matchingReferences" will be always empty array.

const dataStatus = getDataStatus({
    input,
    matchingReferences: Object.keys(finalData).map(id => finalData[id]),
    referenceRecord,
    translate,
});

Other information:
There was already issue opened
#5731
https://stackoverflow.com/questions/65488613/react-admin-referenceinput-doesnt-show-loading-linearprogress-while-loading?noredirect=1#comment115901905_65488613

CodeSandbox
https://codesandbox.io/s/admiring-monad-uludk?file=/src/dataProvider.js

Environment

  • React-admin 3.11.3
no_loader.mp4
@djhi
Copy link
Collaborator

djhi commented Jan 28, 2021

Yes, we had a fix which has been reverted in 3.11 because it introduced other issues. We fixed it in 3.12 by giving the loader display responsability to the ReferenceInput children. See #5767

@djhi djhi closed this as completed Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants