Skip to content

Commit 72c665b

Browse files
committed
Update AutocompleteArrayInput documentation
1 parent cd81594 commit 72c665b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/AutocompleteArrayInput.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ The form value for the source must be an array of the selected values, e.g.
6868
| `filterToQuery` | Optional | `string` => `Object` | `q => ({ q })` | How to transform the searchText into a parameter for the data provider |
6969
| `inputText` | Optional | `Function` | `-` | Required if `optionText` is a custom Component, this function must return the text displayed for the current selection. |
7070
| `matchSuggestion` | Optional | `Function` | `-` | Required if `optionText` is a React element. Function returning a boolean indicating whether a choice matches the filter. `(filter, choice) => boolean` |
71+
| `offline` | Optional | `ReactNode` | - | What to render when there is no network connectivity when fetching the choices |
7172
| `onChange` | Optional | `Function` | `-` | A function called with the new value, along with the selected records, when the input value changes |
7273
| `onCreate` | Optional | `Function` | `-` | A function called with the current filter value when users choose to create a new choice. |
7374
| `optionText` | Optional | `string` | `Function` | `Component` | `name` | Field name of record to display in the suggestion item or function which accepts the correct record as argument (`(record)=> {string}`) |
@@ -323,6 +324,27 @@ const filterToQuery = searchText => ({ name_ilike: `%${searchText}%` });
323324
</ReferenceArrayInput>
324325
```
325326

327+
## `offline`
328+
329+
`<AutocompleteArrayInput>` can display a custom message when it can't fetch the choices because there is no network connectivity, thanks to the `offline` prop.
330+
331+
```jsx
332+
<ReferenceArrayInput source="user_id" reference="users">
333+
<AutocompleteArrayInput offline={<span>No network, could not fetch data</span>} />
334+
</ReferenceArrayInput>
335+
```
336+
337+
You can pass either a React element or a string to the `offline` prop:
338+
339+
```jsx
340+
<ReferenceArrayInput source="user_id" reference="users">
341+
<AutocompleteArrayInput offline={<span>No network, could not fetch data</span>} />
342+
</ReferenceArrayInput>
343+
<ReferenceArrayInput source="user_id" reference="users">
344+
<AutocompleteArrayInput offline="No network, could not fetch data" />
345+
</ReferenceArrayInput>
346+
```
347+
326348
## `onChange`
327349

328350
Use the `onChange` prop to get notified when the input value changes.

0 commit comments

Comments
 (0)