Skip to content

Commit 82eb4aa

Browse files
tecoholicfarhaanbukhsh
authored andcommitted
fix: subsection active state retained after sidebar closed
1 parent 3d167f1 commit 82eb4aa

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/components/SubSectionAnalyticsButton.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ import { useAspectsSidebarContext } from '../hooks';
55
import { Block, SubSection, castToBlock } from '../types';
66

77
export function SubSectionAnalyticsButton({ subsection }: { subsection: SubSection }) {
8-
const { activeBlock, setActiveBlock, setSidebarOpen } = useAspectsSidebarContext();
8+
const {
9+
activeBlock, sidebarOpen, setActiveBlock, setSidebarOpen,
10+
} = useAspectsSidebarContext();
911
if (!subsection.graded) {
1012
return null;
1113
}
1214
return (
1315
<IconButton
1416
alt="Analytics"
1517
iconAs={AutoGraph}
16-
isActive={activeBlock?.id === subsection.id}
18+
isActive={sidebarOpen && (activeBlock?.id === subsection.id)}
1719
onClick={() => {
1820
setSidebarOpen(true);
1921
setActiveBlock(castToBlock(subsection) as Block);

0 commit comments

Comments
 (0)