Position 'Sticky' of Select Checkbox first column cells malfunctioning
Expected Behavior
The first column Select cells (check boxes) should not behave stickily when scrolling. As the row disappears during scrolling the check box cell should also scroll and disappear. The component class src/components/TableSelectCell has a fixedHeader css class that triggers on the fixedHeader option. I don't think the table body checkbox columns are related to the fixedHeader. Is that the intended behavior that the checkboxes in the whole first column also remain fixed during horizontal scrolling?
I think what's needed is that the TableSelectCell which is also a headerCell have the position 'sticky' as opposed to a normal TableSelectCell.
Current Behavior
The checkbox select cell (in the first column) is sticking even after it's corresponding row is scrolled off the screen.
Steps to Reproduce (for bugs)
1.Set fixedHeader option true and 'responsive' option to 'scroll'. Leave 'selectableRows' option true. 2.Let some of the subsequent rows in the table contain text spanning many lines, so that they are larger in height than the header row. This malfunction is more apparent during this scenario. 3.While scrolling you should see the checkbox sticking after reaching the top of the containing block.
How I found a workaround for the issue:
-
I added the following MuiTheme override
MUIDataTableSelectCell: { fixedHeader: { position: 'relative' }, headerCell: { position: 'sticky' } }, The above removes the stickiness of the checkboxes, which is not optimal, but a reasonable workaround. I needed to preserve the stickiness of the headerCell which is the SlectAll checkbox, which is the headerCell class shown above.
Your Environment
I'm using Chrome Version 71.0.3578.98 (Official Build) (64-bit) on a Mac
| Tech | Version |
|---|---|
| Material-UI | 3.8.1 |
| MUI-datatables | 2.0.0-beta-45 |
| React | 16.7.0 |
| browser | Chrome 71.0.3578.98 |
| etc |
Facing the same issue as well but can't seem to get the solution to work.
Here's what I have:
const getMuiTheme = () => createMuiTheme({
overrides: {
MUIDataTableBodyCell: {
root: {
backgroundColor: "#FF0000"
}
},
MUIDataTableSelectCell: {
fixedHeader: {
position: 'relative'
},
headerCell: {
position: 'sticky'
}
},
}
});
const markup = renderToString((
<Provider store={store}>
<StaticRouter context={context} location={req.url}>
<JssProvider generateClassName={generateClassName} registry={sheetsRegistry}>
<MuiThemeProvider theme={getMuiTheme()} sheetsManager={new Map()}>
<App />
</MuiThemeProvider>
</JssProvider>
</StaticRouter>
</Provider>
));
Did I implement the getMuiTheme right?
This is what I have for my render function return value:
return (
<MuiThemeProvider theme={this.getMuiTheme()}>
<MUIDataTable title={self.props.title}
data={contactsArray}
columns={columnDefinitions}
options={options}
/>
</MuiThemeProvider>
);
Perhaps this is how it should be . If this doesnt resolve I can paste my getMuiTheme overrides.
This is what I have for my render function return value:
return ( <MuiThemeProvider theme={this.getMuiTheme()}> <MUIDataTable title={self.props.title} data={contactsArray} columns={columnDefinitions} options={options} /> </MuiThemeProvider> );Perhaps this is how it should be . If this doesnt resolve I can paste my getMuiTheme overrides.
this solved it for me as well. Thanks!
In case you want to remove the stickiness of the all the boxes including the header one, here are the overrides you might want to use :
overrides: {
MUIDataTableSelectCell: {
fixedHeader: {
position: "relative"
},
headerCell: {
position: "relative"
}
},
MUIDataTableHeadCell: {
fixedHeader: {
position: "relative"
}
}
}
});```
This is not a malfunction. It is important to make the checkboxes sticky by default, as header options and selectableness should remain possible from any position in the table, just as do the column header sort options and the toolbar. In terms of UX, if a user scrolls away, or is on a small screen, before they know what's going on with the table, they may not even know what options are available to them.
As pointed out above, you can override this behavior in CSS, which should be enough to handle exceptional cases.