From 7f40ce8dde4d6b5a915eaf6a349a4b0482419a06 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 31 May 2024 10:54:17 -0400 Subject: [PATCH] Fix advance buttons showing up for the spotlight speaker --- src/tile/SpotlightTile.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tile/SpotlightTile.tsx b/src/tile/SpotlightTile.tsx index f77ce4cf..a171fe4f 100644 --- a/src/tile/SpotlightTile.tsx +++ b/src/tile/SpotlightTile.tsx @@ -204,8 +204,9 @@ export const SpotlightTile = forwardRef( const [visibleId, setVisibleId] = useState(vms[0].id); const latestVms = useLatest(vms); const latestVisibleId = useLatest(visibleId); - const canGoBack = visibleId !== vms[0].id; - const canGoToNext = visibleId !== vms[vms.length - 1].id; + const visibleIndex = vms.findIndex((vm) => vm.id === visibleId); + const canGoBack = visibleIndex > 0; + const canGoToNext = visibleIndex !== -1 && visibleIndex < vms.length - 1; // To keep track of which item is visible, we need an intersection observer // hooked up to the root element and the items. Because the items will run