Merge pull request #273 from GRA0007/fix/palette-bounds

Prevent colour index from escaping the bounds of the palette
This commit is contained in:
Benji Grant 2023-06-14 13:15:12 +10:00 committed by GitHub
commit 999c629c93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -74,7 +74,7 @@ const AvailabilityViewer = ({ times, people, table }: AvailabilityViewerProps) =
if (tempFocus) {
peopleHere = peopleHere.filter(p => p === tempFocus)
}
const color = palette[tempFocus && peopleHere.length ? max : peopleHere.length - min]
const color = palette[(tempFocus && peopleHere.length) ? Math.min(max, palette.length - 1) : Math.max(peopleHere.length - min, 0)]
return <div
key={y}