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

Add TextArrayInput to edit arrays of strings #10384

Merged
merged 6 commits into from
Dec 5, 2024
Merged

Add TextArrayInput to edit arrays of strings #10384

merged 6 commits into from
Dec 5, 2024

Conversation

fzaninotto
Copy link
Member

@fzaninotto fzaninotto commented Nov 26, 2024

Problem

Our various array input components don't support the simple case of editing an array of strings with no choices.

Solution

2 possibilities:

  1. Tweak the AutocompleteArrayInput to support simple addition with freeSolo. This is not possible because this input heavily relies on suggestions, and can't take a value outside of its choices. Even the onCreate support uses a special choice.
  2. Implement a new, simpler component based on MUI's <Autocomplete> component.

I tried 1. but failed, so I went for 2.

DX

import { Create, SimpleForm, TextArrayInput, TextInput } from 'react-admin';

export const EmailCreate = () => (
    <Create>
        <SimpleForm>
            <TextArrayInput source="to" />
            <TextInput source="subject" />
            <TextInput source="body" multiline minRows={5} />
        </SimpleForm>
    </Create>
);
TextArrayInput.mp4

How To Test

Launch the storybook and check out the ra-ui-materialui/inputs/TextArrayInput stories at http://localhost:9010/?path=/story/ra-ui-materialui-input-textarrayinput--basic.

To Do

  • Add component
  • Add stories
  • Add tests
  • Add Documentation
  • Reference it in other doc pages to make it discoverable

@fzaninotto fzaninotto added the WIP Work In Progress label Nov 26, 2024
@fzaninotto fzaninotto added RFR Ready For Review and removed WIP Work In Progress labels Nov 27, 2024
@fzaninotto fzaninotto added this to the 5.5.0 milestone Nov 27, 2024
@slax57 slax57 self-requested a review December 3, 2024 14:17
Co-authored-by: Jean-Baptiste Kaiser <[email protected]>
@fzaninotto
Copy link
Member Author

Review applied

examples/simple/src/data.tsx Outdated Show resolved Hide resolved
@slax57 slax57 merged commit 2684465 into next Dec 5, 2024
15 checks passed
@slax57 slax57 deleted the text-array-input branch December 5, 2024 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants