Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.

Commit ce18cb0

Browse files
authored
style(gatsby-theme-docz): keep NavGroup opened on item click (#1211)
1 parent 32a3b3c commit ce18cb0

File tree

1 file changed

+6
-2
lines changed
  • core/gatsby-theme-docz/src/components/NavGroup

1 file changed

+6
-2
lines changed

core/gatsby-theme-docz/src/components/NavGroup/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
/** @jsx jsx */
22
import { jsx } from 'theme-ui'
33
import React from 'react'
4+
import { useCurrentDoc } from 'docz'
45

56
import * as styles from './styles'
67
import { NavLink } from '../NavLink'
78
import { ChevronDown } from '../Icons'
89

910
export const NavGroup = ({ item }) => {
10-
const { menu } = item
11-
const [subheadingsVisible, setShowsubheadings] = React.useState(false)
11+
const current = useCurrentDoc()
12+
const { name, menu } = item
13+
const [subheadingsVisible, setShowsubheadings] = React.useState(
14+
current.menu === name
15+
)
1216
const toggleSubheadings = () => setShowsubheadings(!subheadingsVisible)
1317

1418
return (

0 commit comments

Comments
 (0)