Skip to content

Commit 22900e6

Browse files
authored
Merge pull request #8656 from marmelab/fix-simpleform-mobile
Fix Save tool bar hiding content on mobile
2 parents 29731a7 + 7bd453a commit 22900e6

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

examples/simple/src/posts/PostCreate.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const PostCreateToolbar = props => {
5151
redirect('show', 'posts', data.id);
5252
},
5353
}}
54+
sx={{ display: { xs: 'none', sm: 'flex' } }}
5455
/>
5556
<SaveButton
5657
label="post.action.save_and_add"
@@ -81,6 +82,7 @@ const PostCreateToolbar = props => {
8182
},
8283
}}
8384
transform={data => ({ ...data, average_note: 10 })}
85+
sx={{ display: { xs: 'none', sm: 'flex' } }}
8486
/>
8587
</Toolbar>
8688
);

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

+13-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { ReactElement, ReactNode } from 'react';
33
import PropTypes from 'prop-types';
44
import { Form, FormProps } from 'ra-core';
55
import { Stack, CardContent, SxProps, StackProps } from '@mui/material';
6+
import { styled } from '@mui/material/styles';
7+
68
import { Toolbar } from './Toolbar';
79

810
/**
@@ -76,11 +78,17 @@ export interface SimpleFormProps
7678
sx?: SxProps;
7779
}
7880

79-
const DefaultComponent = ({ children, sx, className }) => (
80-
<CardContent sx={sx} className={className}>
81-
{children}
82-
</CardContent>
83-
);
81+
const PREFIX = 'RaSimpleForm';
82+
83+
const DefaultComponent = styled(CardContent, {
84+
name: PREFIX,
85+
overridesResolver: (props, styles) => styles.root,
86+
})(({ theme }) => ({
87+
[theme.breakpoints.down('sm')]: {
88+
paddingBottom: '5em',
89+
},
90+
}));
91+
8492
const DefaultToolbar = <Toolbar />;
8593

8694
const sanitizeRestProps = ({

0 commit comments

Comments
 (0)