Skip to content
Open
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
12 changes: 10 additions & 2 deletions docs/data/material/components/table/CollapsibleTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ function createData(name, calories, fat, carbs, protein, price) {
function Row(props) {
const { row } = props;
const [open, setOpen] = React.useState(false);
const [exited, setExited] = React.useState(true);

return (
<React.Fragment>
<TableRow sx={{ '& > *': { borderBottom: 'unset' } }}>
<TableCell>
<IconButton
aria-label="expand row"
aria-expanded={open}
size="small"
onClick={() => setOpen(!open)}
>
Expand All @@ -61,9 +63,15 @@ function Row(props) {
<TableCell align="right">{row.carbs}</TableCell>
<TableCell align="right">{row.protein}</TableCell>
</TableRow>
<TableRow>
<TableRow aria-hidden={!open && exited ? true : undefined}>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={6}>
<Collapse in={open} timeout="auto" unmountOnExit>
<Collapse
in={open}
timeout="auto"
unmountOnExit
onEnter={() => setExited(false)}
onExited={() => setExited(true)}
>
<Box sx={{ margin: 1 }}>
<Typography variant="h6" gutterBottom component="div">
History
Expand Down
12 changes: 10 additions & 2 deletions docs/data/material/components/table/CollapsibleTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ function createData(
function Row(props: { row: ReturnType<typeof createData> }) {
const { row } = props;
const [open, setOpen] = React.useState(false);
const [exited, setExited] = React.useState(true);

return (
<React.Fragment>
<TableRow sx={{ '& > *': { borderBottom: 'unset' } }}>
<TableCell>
<IconButton
aria-label="expand row"
aria-expanded={open}
size="small"
onClick={() => setOpen(!open)}
>
Expand All @@ -67,9 +69,15 @@ function Row(props: { row: ReturnType<typeof createData> }) {
<TableCell align="right">{row.carbs}</TableCell>
<TableCell align="right">{row.protein}</TableCell>
</TableRow>
<TableRow>
<TableRow aria-hidden={!open && exited ? true : undefined}>
<TableCell style={{ paddingBottom: 0, paddingTop: 0 }} colSpan={6}>
<Collapse in={open} timeout="auto" unmountOnExit>
<Collapse
in={open}
timeout="auto"
unmountOnExit
onEnter={() => setExited(false)}
onExited={() => setExited(true)}
>
<Box sx={{ margin: 1 }}>
<Typography variant="h6" gutterBottom component="div">
History
Expand Down
Loading