react-admin: [Bug] ReferenceInput/ReferenceArrayInput sometimes doesn't show the selected values
What you were expecting:
ReferenceInput/ReferenceyArrayInput
should always show the selected values that come from the REST API.
What happened instead:
Selected values sometimes don’t always show up. They instead show up for about a second and suddenly disappear. If I use Refresh button, sometimes the values show up, sometimes not. According to my finding, this seems to happen when there is another usage of ReferenceInput
or ReferenceArrayInput
that refers to the same resource type as that of the one being created/edited (check the Parent category
reference in the example below).
Steps to reproduce (and the code): I have an example where I have resources for products, product categories and product attributes. Each product category can have 1 or more attributes and 0 or 1 parent category. Following is the code:
<ReferenceInput label='Parent category' source='parentId' reference='Category'>
<SelectInput label='Parent category' optionText='title' />
</ReferenceInput>
<ReferenceArrayInput label='Attributes' source='attributeIds' reference='Attribute'>
<SelectArrayInput label='Attributes' optionText='title' />
</ReferenceArrayInput>
The transform from attributes
and category
properties of a Category is done via response mapping in data provider like so:
'GET_ONE': {
query: gql`query getCategory($id: ID!) {
item: getCategory(id: $id) {
${returnedFields}
}
}`,
variables: params,
parseResponse: response => {
const category = response.data.item;
if (category.parent) {
category.parentId = category.parent.id;
}
if (category.attributes) {
category.attributeIds = category.attributes.map(a => a.id);
}
return { data: category };
}
},
Environment
- React-admin version: 2.6.1
- React version: 16.7.0
- Browser: Chrome
- Stack trace (in case of a JS error): No errors
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 17 (8 by maintainers)
Sorry @kopax , my mistake.
This is my experience when using ReferenceInput. When i click save, some checked box disappear and showing after update active success.
Hay quá! Tai sao việc tiẻng việt?