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

Fix cannot remove form toolbar with toolbar={false} #7738

Merged
merged 1 commit into from
May 23, 2022
Merged
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
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 @@ -124,7 +124,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 @@ -94,7 +94,7 @@ export const TabbedFormView = (props: TabbedFormViewProps): ReactElement => {
: null;
})}
</Component>
{toolbar}
{toolbar !== false ? toolbar : null}
</Root>
);
};
Expand Down Expand Up @@ -126,7 +126,7 @@ export interface TabbedFormViewProps {
formRootPathname?: string;
syncWithLocation?: boolean;
tabs?: ReactElement;
toolbar?: ReactElement;
toolbar?: ReactElement | false;
sx?: SxProps;
}

Expand Down