-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Missing items in ArrayInput with SimpleIterator #6900
Comments
@horaklukas, thanks for the report. Did you change anything in the code sandbox? |
Oh, sorry, forgot to mention. I added |
@horaklukas, try it again in your codesandbox, but changing :
At the end of |
You're right, it works after that change although it doesn't work in my code. Anyway, even with this change, it's still incorrect and it leads to this error again
because all <CSSTransition
// ids.current is empty array because of memoization
key={ids.current[index]} |
I'll try to look into this and see what I can find |
After #6932 gets merged, we should try if it fixes this issue |
Ok, I'll give it a try, thanks |
If you remove the backlinks fromthe dataProvider like that you are going to have weird results with the cached version of the dataProvider, I don't think this is a valid use case. |
@horaklukas, I think I misunderstood your issue, I believe this is indeed a bug. In fact, you have reached some of the same conclusions that in #5289. |
I have the same problem, when you inspect an element you will see that the reason is "fade-enter" class.
In my case, it doesn't even help to restore react-admin to v3.0.0. |
i have same issue, my model "questions" have an array "responses" that is only available in the method getOne of the dataProvider. In the getList my API respond with only a few fields. |
Experiencing the same issue here. <SimpleFormIterator> within <ArrayInput> doesn't render any but the last element of the array. The other ones stay empty until the page is refreshed. I also noticed that the "fade-enter" attribute isn't triggered in any but the last <li> element Any clues on solving this? |
I am having the same issue |
+1. Same issue. Only display last item but not other items. |
I am also experiencing this issue. The first element of a SimpleFormIterator does not load, but appears after page refresh. Is it possible to disable the fade animation for SimpleFormIterator as a workaround? |
I have a very simple workaround. Disable the animation. The form function still work.
|
@tong-bluehill Thank you! |
@tong-bluehill Thank you very much!!! |
Based on @tong-bluehill workaround:
This is how I've solved in "react-admin": "^3.19.11",
|
I've just updated to |
For v3 I fixed this error by providing I only needed this because my <ArrayInput
source="spec.things"
label="Things"
defaultValue={[{}]}
>
<SimpleFormIterator>
<TextInput
source="name"
fullWidth
/>
<OtherCustomInput source="yada" />
</SimpleFormIterator>
</ArrayInput> |
The workaround that I detailed above only works until you add a 2nd array item. Then, whenever you edit that record it has the same error because it starts with a The workaround for v3 that finally did it for me was to only render the /** True if we are CURRENTLY loading. */
const isLoading = useLoading();
/** True if we WERE loading. */
const wasLoadingRef = React.useRef(false);
/** True if we WERE loading and now we're NOT. */
const isLoaded = React.useMemo(() => {
if (isLoading) {
wasLoadingRef.current = true;
return false;
} else {
return wasLoadingRef.current;
}
}, [isLoading]);
return (
<Edit {...props}>
<SimpleForm>
<TextInput source="yada" />
{isLoaded && (
<ArrayInput
source="spec.queries"
label="Queries"
>
<SimpleFormIterator>
<TextInput source="whatever" />
{/* ... */}
</SimpleFormIterator>
</ArrayInput>
)}
</SimpleForm>
</Edit> |
This just in: The last workaround doesn't work all the time either. It does work some of the time. So, the workaround will now be to ignore this error until we upgrade this project :) |
With the release of react-admin v5, react-admin v3 has reached its end of life. We won't fix bugs or make any new release on the 3.x branch. We recommend that you switch to a more recent version of react-admin. So I'm closing this issue as we won't fix it. |
What you were expecting:
When I open posts list and then open post detail with iterated data (backlinks) using
ArrayInput
andSimpleFormIterator
, all backlinks are visible.What happened instead:
No backlink is visible. After page refresh all backlinks are back there.
Steps to reproduce:
backlinks
property, because it's not needed in the list3
) and go to tab "Miscellaneous" - api return detail of post containing backlinksRelated code:
https://codesandbox.io/s/frosty-tess-qzbxb?file=/src/posts/PostEdit.tsx
I did some debugging and found out that problem is probably inside
SimpleFormIterator
at lines 59-75. When the detail is loading andfields
is empty, the nextId is initialized with0
value which meansids
become empty array. Once the detail is loaded,nextId
norids
is reevaluated and remain as it is which meansids
is empty array, butfields
contains backlinksOther information:
I suppose it's related to these issues
Environment
I know the another cause of the issue is that the entity (post in this case) has different shape for list and for detail, but it's a common use case for use, because some entities can be huge and we need only few simple fields for distinguishing them in a list.
Is it an antipattern for RA to have different entity shapes between endpoints?
The text was updated successfully, but these errors were encountered: