Skip to content

Commit 54c860b

Browse files
authored
Merge pull request #7738 from marmelab/fix-forms-toolbar-boolean-support
Fix Forms Components To Support false for toolbar prop
2 parents 74680dc + 77e0030 commit 54c860b

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

packages/ra-ui-materialui/src/form/SimpleForm.stories.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,13 @@ export const StackProps = () => (
6666
</SimpleForm>
6767
</Wrapper>
6868
);
69+
70+
export const NoToolbar = () => (
71+
<Wrapper>
72+
<SimpleForm toolbar={false}>
73+
<TextInput source="title" fullWidth />
74+
<TextInput source="author" />
75+
<NumberInput source="year" />
76+
</SimpleForm>
77+
</Wrapper>
78+
);

packages/ra-ui-materialui/src/form/SimpleForm.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const SimpleForm = (props: SimpleFormProps) => {
5252
{children}
5353
</Stack>
5454
</Component>
55-
{toolbar}
55+
{toolbar !== false ? toolbar : null}
5656
</Form>
5757
);
5858
};

packages/ra-ui-materialui/src/form/TabbedForm.stories.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,15 @@ export const CustomLayout = () => (
7878
</TabbedForm>
7979
</Wrapper>
8080
);
81+
82+
export const NoToolbar = () => (
83+
<Wrapper>
84+
<TabbedForm toolbar={false}>
85+
<FormTab label="main">
86+
<TextInput source="title" fullWidth />
87+
<TextInput source="author" sx={{ width: '50%' }} />
88+
<NumberInput source="year" sx={{ width: '50%' }} />
89+
</FormTab>
90+
</TabbedForm>
91+
</Wrapper>
92+
);

packages/ra-ui-materialui/src/form/TabbedForm.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export interface TabbedFormProps
125125
resource?: string;
126126
syncWithLocation?: boolean;
127127
tabs?: ReactElement;
128-
toolbar?: ReactElement;
128+
toolbar?: ReactElement | false;
129129
warnWhenUnsavedChanges?: boolean;
130130
}
131131

packages/ra-ui-materialui/src/form/TabbedFormView.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export const TabbedFormView = (props: TabbedFormViewProps): ReactElement => {
9898
: null;
9999
})}
100100
</Component>
101-
{toolbar}
101+
{toolbar !== false ? toolbar : null}
102102
</Root>
103103
);
104104
};
@@ -130,7 +130,7 @@ export interface TabbedFormViewProps {
130130
formRootPathname?: string;
131131
syncWithLocation?: boolean;
132132
tabs?: ReactElement;
133-
toolbar?: ReactElement;
133+
toolbar?: ReactElement | false;
134134
sx?: SxProps;
135135
}
136136

0 commit comments

Comments
 (0)