Skip to content

Commit 11992e1

Browse files
committed
Review
1 parent 685706d commit 11992e1

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

docs/InPlaceEditor.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Use `<InPlaceEditor>` inside a `RecordContext` (e.g., under `<List>` or `<Show>`
2424
```tsx
2525
import { Show, InPlaceEditor } from 'react-admin';
2626
import { Stack, Box, Typography } from '@mui/material';
27+
import { AvatarField, CustomerActions } from './components';
2728

2829
const CustomerShow = () => (
2930
<Show>
@@ -65,7 +66,6 @@ const choices = [
6566

6667
// ...
6768
<InPlaceEditor
68-
source="access"
6969
editor={
7070
<SelectInput
7171
source="access"
@@ -169,7 +169,6 @@ For example, to use a `<SelectInput>` in edit mode, you can use the following co
169169
{% raw %}
170170
```tsx
171171
<InPlaceEditor
172-
source="access"
173172
editor={
174173
<SelectInput
175174
source="access"

packages/ra-ui-materialui/src/input/InPlaceEditor/InPlaceEditor.Card.stories.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
TestMemoryRouter,
2626
NotificationContextProvider,
2727
UndoableMutationsContextProvider,
28+
required,
2829
} from 'ra-core';
2930
import fakeRestDataProvider from 'ra-data-fakerest';
3031
import polyglotI18nProvider from 'ra-i18n-polyglot';
@@ -336,6 +337,7 @@ export const Complex = () => {
336337
helperText={false}
337338
autoFocus
338339
SelectProps={{ defaultOpen: true }}
340+
validate={required()}
339341
sx={{
340342
'& .MuiInput-root': {
341343
marginTop: 0,

packages/ra-ui-materialui/src/input/InPlaceEditor/InPlaceEditor.stories.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
TestMemoryRouter,
1212
NotificationContextProvider,
1313
UndoableMutationsContextProvider,
14+
required,
1415
} from 'ra-core';
1516
import fakeRestDataProvider from 'ra-data-fakerest';
1617
import polyglotI18nProvider from 'ra-i18n-polyglot';
@@ -219,7 +220,7 @@ export const SX = () => (
219220
</Wrapper>
220221
);
221222

222-
export const EditbleDataTable = () => (
223+
export const EditableDataTable = () => (
223224
<TestMemoryRouter>
224225
<QueryClientProvider client={new QueryClient()}>
225226
<DataProviderContext.Provider
@@ -325,6 +326,7 @@ export const EditbleDataTable = () => (
325326
margin="none"
326327
label={false}
327328
variant="standard"
329+
validate={required()}
328330
autoFocus
329331
SelectProps={{
330332
defaultOpen:

packages/ra-ui-materialui/src/input/InPlaceEditor/InPlaceEditor.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ export const InPlaceEditor = (props: InPlaceEditorProps) => {
8282
'InPlaceEditor requires either a source prop or children or editor prop'
8383
);
8484
}
85+
if (mutationMode === 'undoable' && !notifyOnSuccess) {
86+
throw new Error(
87+
'InPlaceEditor requires notifyOnSuccess to be true when mutationMode is undoable'
88+
);
89+
}
8590

8691
const submitButtonRef = useRef<HTMLButtonElement>(null);
8792

0 commit comments

Comments
 (0)