Added error boundary to the ByAsset page. Added useRef to the SimpleTable utility.

This commit is contained in:
2024-02-14 08:48:21 -08:00
parent 4d20bf73b7
commit 57fc5583f7
3 changed files with 32 additions and 26 deletions

View File

@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, {useRef, useState} from 'react';
import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell';
@@ -48,6 +48,7 @@ const cssTopControls = {
*/
export default ({columns, rows, options}) => {
const [selected, setSelected] = useState(undefined);
const tableContainer = useRef(null)
let selectRow = (e, row) => {
setSelected(row);
@@ -67,6 +68,7 @@ export default ({columns, rows, options}) => {
const addRow = () => {
setEdited({});
setTimeout(() => tableContainer.current.scrollTo({top: 0, left: 0, behavior: "smooth"}),0)
}
let containerStyle = options.maxHeight ? {maxHeight: options.maxHeight} : {}
@@ -131,7 +133,7 @@ export default ({columns, rows, options}) => {
{options.add && <Button variant="text" className="button" onClick={addRow}>Add</Button>}
{options.remove && _.isFunction(options.remove) && <Button disabled={!selected} variant='text' className='button' onClick={() => {selected && options.remove(selected)}}>Remove</Button>}
</div>
<TableContainer className="simpleTable" component={Paper} style={containerStyle}>
<TableContainer ref={tableContainer} className="simpleTable" component={Paper} style={containerStyle}>
<Table size="small" aria-label="Table" tabIndex="0" onKeyDown={keyHandler}>
<TableHead className="sticky">
<TableRow>