Skip to content

Commit

Permalink
Fix ItemTable props/state issues causing failure to render
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Campbell committed Nov 16, 2020
1 parent 01a3653 commit 27bca3e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/AppView/AppView.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default function AppView({ setDarkMode }){
<Box className={classes.leftCol}>
<ItemTableAppBar title="webqueue2" setDarkMode={setDarkMode} />
<QueueSelector queues={queueCounts} selectedQueues={selectedQueues} setSelectedQueues={setSelectedQueues} />
<ItemTable data={items} onRowClick={ _ => console.log("Clicked!") }/>
<ItemTable data={items} rowCanBeSelected={sidebarOpen}/>
</Box>

<Box className={clsx(classes.rightCol, sidebarOpen && classes.rightColShift)}>
Expand Down
5 changes: 4 additions & 1 deletion src/components/ItemTable/ItemTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ArrowDownward, ArrowUpward } from "@material-ui/icons";


export default function ItemTable({ data, rowCanBeSelected }) {
const [selectedRow, setSelectedRow] = useState({ queue: null, number: null});

const theme = useTheme();
const useStyles = makeStyles({
Expand Down Expand Up @@ -127,7 +128,7 @@ export default function ItemTable({ data, rowCanBeSelected }) {
<TableRow
onClick={() => {
history.push(`/${row.original.queue}/${row.original.number}`);
setSelecetedRow({ queue: row.original.queue, number: row.original.number });
setSelectedRow({ queue: row.original.queue, number: row.original.number });
}}
// This functionality should be achieved by using the selected prop and
// overriding the selected class but this applied the secondary color at 0.08% opacity.
Expand Down Expand Up @@ -159,6 +160,8 @@ ItemTable.propTypes = {
};

ItemTable.defaultProps = {
/** The items to display in the table. */
"items": [],
/** A state variable determining whether a row can be selected or not. */
"rowCanBeSelected": true
};

0 comments on commit 27bca3e

Please sign in to comment.