react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

ReferenceArrayInput with AutocompleteArrayInput flickers and resets value on search when used with format and parse

Open tomek3e opened this issue 2 years ago • 4 comments

What you were expecting: When using AutocompleteArrayInput with a ReferenceArrayInput with parse/format options:

  • the options list should not flicker
  • the input value should not reset itself

What happened instead:

  • the options list values flicker
  • the input value resets itself

Steps to reproduce:

  1. Open code sandbox
  2. In the preview window, go to Comments list
  3. Click on the icon to create a new comment
  4. Select any value(s) in the Comments input
  5. Enter any few characters

Related code: CodeSandox: https://codesandbox.io/s/array-reference-input-xrrv94?file=/src/posts/PostCreate.tsx

Environment

  • React-admin version: 4.7.1

tomek3e avatar Jan 23 '23 11:01 tomek3e

Reproduced, thanks

slax57 avatar Jan 23 '23 13:01 slax57

HI, I updated the CodeSanbox to react-admin 4.7.2 but the issue still persist with parse & format options.

tomek3e avatar Jan 30 '23 10:01 tomek3e

Indeed! I tried to make sure the format and parse props were not causing the re-render by moving them to a const, but the issue is still there. The issue is not present however when you remove the format and parse props (which is what the PR #8599 fixed). Reopening

slax57 avatar Jan 30 '23 13:01 slax57

This actually makes sense inside a ReferenceArrayInput as it expects a specific format for the values (array of ids). @tomek3e, would you mind explaining your use case? Otherwise, I'll mark this as a documentation issue.

djhi avatar Jun 23 '23 13:06 djhi