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

[Doc] Explain openOnFocus in <AutocompleteInput> with StrictMode #10442

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/AutocompleteArrayInput.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ const CreateRole = () => {
```
{% endraw %}

**Tip**: In development with `React.StrictMode`, you may run into an issue where the `<AutocompleteInput>` menu reopens after clicking the create item when the [`openOnFocus`](https://mui.com/material-ui/api/autocomplete/#autocomplete-prop-openOnFocus) prop is set to `true` which is the default with React-admin. If that bothers you, set the `openOnFocus` prop to `false`.

If you just need to ask users for a single string to create the new option, you can use [the `onCreate` prop](#oncreate) instead.

If you're in a `<ReferenceArrayInput>` or `<ReferenceManyToManyInput>`, the `handleSubmit` will need to create a new record in the related resource. Check the [Creating New Choices](#creating-new-choices) for an example.
Expand Down
2 changes: 2 additions & 0 deletions docs/AutocompleteInput.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ const CreateCategory = () => {
```
{% endraw %}

**Tip**: In development with `React.StrictMode`, you may run into an issue where the `<AutocompleteInput>` menu reopens after clicking the create item when the [`openOnFocus`](https://mui.com/material-ui/api/autocomplete/#autocomplete-prop-openOnFocus) prop is set to `true` which is the default with React-admin. If that bothers you, set the `openOnFocus` prop to `false`.

If you want to customize the label of the "Create XXX" option, use [the `createItemLabel` prop](#createitemlabel).

If you just need to ask users for a single string to create the new option, you can use [the `onCreate` prop](#oncreate) instead.
Expand Down
1 change: 1 addition & 0 deletions examples/simple/src/comments/CommentEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ const CommentEdit = props => {
return title.includes(filterValue);
}}
optionText={<OptionRenderer />}
openOnFocus={false}
inputText={inputText}
/>
</ReferenceInput>
Expand Down
1 change: 1 addition & 0 deletions examples/simple/src/posts/PostCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ const PostCreate = () => {
<AutocompleteInput
label="User"
create={<CreateUser />}
openOnFocus={false}
/>
</ReferenceInput>
<FormDataConsumer>
Expand Down
1 change: 1 addition & 0 deletions examples/simple/src/posts/TagReferenceInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const TagReferenceInput = ({
<AutocompleteArrayInput
create={<CreateTag />}
optionText={`name.${locale}`}
openOnFocus={false}
/>
</ReferenceArrayInput>
<Button
Expand Down
Loading