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

ReferenceArrayInput with AutocompleteArrayInput throws error if the array is empty #7685

Closed
ogroppo opened this issue May 11, 2022 · 1 comment · Fixed by #7694
Closed

ReferenceArrayInput with AutocompleteArrayInput throws error if the array is empty #7685

ogroppo opened this issue May 11, 2022 · 1 comment · Fixed by #7694
Labels

Comments

@ogroppo
Copy link

ogroppo commented May 11, 2022

What you were expecting:
I expect the autocomplete to be empty for no references returned i.e. {data: [], total: 0}

What happened instead:
The page throws error
TypeError: Cannot read properties of undefined (reading 'length')

As soon as I create a Tag, the form is happy

Steps to reproduce:
Create a form that relies on a many-to-many rels, i.e. a classic Posts-Tags

export const PostCreate = (props: CreateProps) => (
  <Create title="New post" {...props}>
    <SimpleForm>
      <TextInput source="text" />
      <ReferenceArrayInput label="Tags" reference="tag" source="tags">
        <AutocompleteArrayInput />
      </ReferenceArrayInput>
    </SimpleForm>
  </Create>
);

Screenshot 2022-05-11 at 16 37 46

@slax57 slax57 added the bug label May 16, 2022
@slax57
Copy link
Contributor

slax57 commented May 16, 2022

Reproduced, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants