Skip to content

Commit

Permalink
Merge pull request #7738 from marmelab/fix-forms-toolbar-boolean-support
Browse files Browse the repository at this point in the history
Fix Forms Components To Support false for toolbar prop
  • Loading branch information
slax57 authored May 23, 2022
2 parents 74680dc + 77e0030 commit 54c860b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
10 changes: 10 additions & 0 deletions packages/ra-ui-materialui/src/form/SimpleForm.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,13 @@ export const StackProps = () => (
</SimpleForm>
</Wrapper>
);

export const NoToolbar = () => (
<Wrapper>
<SimpleForm toolbar={false}>
<TextInput source="title" fullWidth />
<TextInput source="author" />
<NumberInput source="year" />
</SimpleForm>
</Wrapper>
);
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/form/SimpleForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const SimpleForm = (props: SimpleFormProps) => {
{children}
</Stack>
</Component>
{toolbar}
{toolbar !== false ? toolbar : null}
</Form>
);
};
Expand Down
12 changes: 12 additions & 0 deletions packages/ra-ui-materialui/src/form/TabbedForm.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,15 @@ export const CustomLayout = () => (
</TabbedForm>
</Wrapper>
);

export const NoToolbar = () => (
<Wrapper>
<TabbedForm toolbar={false}>
<FormTab label="main">
<TextInput source="title" fullWidth />
<TextInput source="author" sx={{ width: '50%' }} />
<NumberInput source="year" sx={{ width: '50%' }} />
</FormTab>
</TabbedForm>
</Wrapper>
);
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/form/TabbedForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export interface TabbedFormProps
resource?: string;
syncWithLocation?: boolean;
tabs?: ReactElement;
toolbar?: ReactElement;
toolbar?: ReactElement | false;
warnWhenUnsavedChanges?: boolean;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/ra-ui-materialui/src/form/TabbedFormView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const TabbedFormView = (props: TabbedFormViewProps): ReactElement => {
: null;
})}
</Component>
{toolbar}
{toolbar !== false ? toolbar : null}
</Root>
);
};
Expand Down Expand Up @@ -130,7 +130,7 @@ export interface TabbedFormViewProps {
formRootPathname?: string;
syncWithLocation?: boolean;
tabs?: ReactElement;
toolbar?: ReactElement;
toolbar?: ReactElement | false;
sx?: SxProps;
}

Expand Down

0 comments on commit 54c860b

Please sign in to comment.