Skip to content

Commit

Permalink
Fix Virtualized Table demo
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Feb 28, 2019
1 parent 3ef133b commit 96599b8
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 16 deletions.
1 change: 0 additions & 1 deletion docs/src/pages/demos/tables/EnhancedTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ RawEnhancedTableHead.propTypes = {
onSelectAllClick: PropTypes.func.isRequired,
order: PropTypes.string.isRequired,
orderBy: PropTypes.string.isRequired,
padding: PropTypes.oneOf(['normal', 'none', 'checkbox']),
rowCount: PropTypes.number.isRequired,
};

Expand Down
14 changes: 6 additions & 8 deletions docs/src/pages/demos/tables/ReactVirtualizedTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import Paper from '@material-ui/core/Paper';
import { AutoSizer, Column, SortDirection, Table } from 'react-virtualized';

const styles = theme => ({
table: {
fontFamily: theme.typography.fontFamily,
},
flexContainer: {
display: 'flex',
alignItems: 'center',
Expand Down Expand Up @@ -95,7 +92,6 @@ class MuiVirtualizedTable extends React.PureComponent {
<AutoSizer>
{({ height, width }) => (
<Table
className={classes.table}
height={height}
width={width}
{...tableProps}
Expand Down Expand Up @@ -153,11 +149,13 @@ MuiVirtualizedTable.propTypes = {
};

MuiVirtualizedTable.defaultProps = {
headerHeight: 56,
rowHeight: 56,
headerHeight: 48,
rowHeight: 48,
};

const WrappedVirtualizedTable = withStyles(styles)(MuiVirtualizedTable);
const VirtualizedTable = withStyles(styles)(MuiVirtualizedTable);

// ---

const data = [
['Frozen yoghurt', 159, 6.0, 24, 4.0],
Expand All @@ -183,7 +181,7 @@ for (let i = 0; i < 200; i += 1) {
function ReactVirtualizedTable() {
return (
<Paper style={{ height: 400, width: '100%' }}>
<WrappedVirtualizedTable
<VirtualizedTable
rowCount={rows.length}
rowGetter={({ index }) => rows[index]}
onRowClick={event => console.log(event)}
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/Table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import clsx from 'clsx';
import withStyles from '../styles/withStyles';
import TableContext from './TableContext';

export const styles = theme => ({
export const styles = {
/* Styles applied to the root element. */
root: {
display: 'table',
width: '100%',
borderCollapse: 'collapse',
borderSpacing: 0,
},
});
};

function Table(props) {
const { classes, className, component: Component, padding, size, ...other } = props;
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Table/Table.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ describe('<Table />', () => {
<TableContext.Consumer>
{value => {
context = value;

return <tbody />;
}}
</TableContext.Consumer>
</Table>,
);

assert.deepStrictEqual(context, {
size: 'normal',
padding: 'normal',
});
});
Expand Down
1 change: 0 additions & 1 deletion packages/material-ui/src/TableCell/TableCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export const styles = theme => ({
'&:last-child': {
paddingRight: 16,
},

'&$paddingCheckbox': {
width: 24, // prevent the checkbox column from growing
padding: '0px 12px 0 16px',
Expand Down
6 changes: 3 additions & 3 deletions packages/material-ui/src/TableCell/TableCell.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ describe('<TableCell />', () => {
assert.strictEqual(wrapper.find('td').hasClass(classes.paddingCheckbox), true);
});

it('should render with the user, root, padding, and dense classes', () => {
const wrapper = mountInTable(<TableCell className="woofTableCell" padding="dense" />);
it('should render with the user, root, padding, and small classes', () => {
const wrapper = mountInTable(<TableCell className="woofTableCell" size="small" />);
assert.strictEqual(wrapper.find('td').hasClass('woofTableCell'), true);
assert.strictEqual(wrapper.find('td').hasClass(classes.root), true);
assert.strictEqual(wrapper.find('td').hasClass(classes.paddingDense), true);
assert.strictEqual(wrapper.find('td').hasClass(classes.sizeSmall), true);
});

it('should render children', () => {
Expand Down

0 comments on commit 96599b8

Please sign in to comment.