1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix scrolling to top when selecting all items in item list layout

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-02-02 08:27:32 +02:00
parent 63ea9d49ac
commit b781fc4ce0
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A

View File

@ -203,31 +203,43 @@ export class ItemListLayoutContent<I extends ItemObject> extends React.Component
} }
renderTableHeader() { renderTableHeader() {
const { customizeTableRowProps, renderTableHeader, isSelectable, isConfigurable, store } = this.props; const { renderTableHeader } = this.props;
if (!renderTableHeader) { if (!renderTableHeader) {
return null; return null;
} }
return (
<TableHead showTopLine nowrap>
<Observer>
{() => {
const { store, isConfigurable, isSelectable, customizeTableRowProps } = this.props;
const enabledItems = this.props.getItems().filter(item => !customizeTableRowProps(item).disabled); const enabledItems = this.props.getItems().filter(item => !customizeTableRowProps(item).disabled);
return ( return (
<TableHead showTopLine nowrap> <>
{isSelectable && ( {isSelectable && (
<TableCell <TableCell
checkbox checkbox
isChecked={store.isSelectedAll(enabledItems)} isChecked={store.isSelectedAll(enabledItems)}
onClick={prevDefault(() => store.toggleSelectionAll(enabledItems))} onClick={prevDefault(() =>
store.toggleSelectionAll(enabledItems),
)}
/> />
)} )}
{renderTableHeader.map((cellProps, index) => ( {renderTableHeader.map(
(cellProps, index) =>
this.showColumn(cellProps) && ( this.showColumn(cellProps) && (
<TableCell key={cellProps.id ?? index} {...cellProps} /> <TableCell key={cellProps.id ?? index} {...cellProps} />
) ),
))} )}
<TableCell className="menu"> <TableCell className="menu">
{isConfigurable && this.renderColumnVisibilityMenu()} {isConfigurable && this.renderColumnVisibilityMenu()}
</TableCell> </TableCell>
</>
);
}}
</Observer>
</TableHead> </TableHead>
); );
} }