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

optionText function not supported on AutocompleteArrayInput with create new item #7010

Closed
nicgirault opened this issue Dec 17, 2021 · 1 comment · Fixed by #7038
Closed
Labels

Comments

@nicgirault
Copy link
Contributor

nicgirault commented Dec 17, 2021

What you were expecting:

When specifying this code:

<AutocompleteArrayInput
        optionText={item => `${item.category}:${item.value}`}
        create={<CreateTagDialog />}
 />

I expect to see a "Create" item at the end of the list of choice

What happened instead:

There is an empty item. I have to write the following code to make it work:

<AutocompleteArrayInput
        optionText={item => {
          if (item.id === '@@ra-create') {
            return item.name
          }
          return `${item.category}:${item.value}`
        }}
        create={<CreateTagDialog />}
 />

Related code:

https://codesandbox.io/s/empty-framework-p8v3q?file=/src/posts/TagReferenceInput.tsx

Environment

  • React-admin version: 3.19.4
@fzaninotto fzaninotto added the bug label Dec 22, 2021
@fzaninotto
Copy link
Member

Reproduced, thanks for the report.

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