Skip to content

Commit

Permalink
Add clarifying comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Campbell committed Nov 27, 2020
1 parent ce280ca commit 1e06378
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/QueueSelector/QueueSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function QueueSelector({ queueSelectorOpen, setQueueSelectorOpen,
const access_token = useToken();
const loading = open && queueCounts.length === 0;

// Get queue counts if QueueSelector is open
useEffect( _ => {
const getQueueCounts = async _ => {
if (access_token === null){
Expand All @@ -35,6 +36,7 @@ export default function QueueSelector({ queueSelectorOpen, setQueueSelectorOpen,

}, [loading, access_token]);

// Delete queue counts if QueueSelector is closed
useEffect(() => {
if (!open) {
setQueueCounts([]);
Expand All @@ -47,6 +49,8 @@ export default function QueueSelector({ queueSelectorOpen, setQueueSelectorOpen,
setSelectedQueues(newValue)
};

// Function to render checkboxes in dropdown
// See `renderOptions` prop at https://material-ui.com/api/autocomplete/#props
const optionRenderer = (option, { selected }) => (
<>
<Checkbox
Expand All @@ -60,6 +64,7 @@ export default function QueueSelector({ queueSelectorOpen, setQueueSelectorOpen,
);

return(
// Box is used for margin because Autocomplete CSS overrides don't work as expected.
<Box margin={`${theme.spacing(1)}px`}>
<Autocomplete
renderInput={(params) => (
Expand Down

0 comments on commit 1e06378

Please sign in to comment.