[go: nahoru, domu]

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

The documentation says that <ReferenceArrayInput> supports the emptyText property, but it does not work. #8425

Open
nptry opened this issue Nov 23, 2022 · 1 comment
Labels

Comments

@nptry
Copy link
nptry commented Nov 23, 2022

Environment

  • React-admin version: 4.5.2

doc: https://marmelab.com/react-admin/AutocompleteArrayInput.html#emptytext

I used this property, but it didn't work:
https://codesandbox.io/s/quizzical-turing-wrjs7q?file=/src/posts/PostCreate.tsx

<AutocompleteArrayInput
          source="roles"
          choices={[
            { id: "admin", name: "Admin" },
            { id: "u001", name: "Editor" },
            { id: "u002", name: "Moderator" },
            { id: "u003", name: "Reviewer" }
          ]}
          emptyText="all"
        />

image

@fzaninotto
Copy link
Member

Confirmed. This is due to a test that specifically excludes arrays in the support of emptyText:

const finalChoices = useMemo(
() =>
// eslint-disable-next-line eqeqeq
emptyText == undefined || isRequired || multiple
? allChoices
: [
{
[optionValue || 'id']: emptyValue,
[typeof optionText === 'string'
? optionText
: 'name']: translate(emptyText, {
_: emptyText,
}),
},
].concat(allChoices),
[
allChoices,
emptyValue,
emptyText,
isRequired,
multiple,
optionText,
optionValue,
translate,
]
);

Why was this test added in the first place? Needs further inquiry.

@fzaninotto fzaninotto added the bug label Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants