mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
Fixes issue related to selected module when user clicks on sidebar
This commit is contained in:
parent
e514f405ae
commit
36ddcf9760
@ -22,10 +22,10 @@ export default function MarkdownList({ pageContext }) {
|
||||
modules[key].push(node)
|
||||
})
|
||||
|
||||
const module_keys = Object.keys(modules).sort()
|
||||
|
||||
const [selectedSubSection, setSelectedSubSection] = useState(0)
|
||||
const [elem, setElem] = useState(
|
||||
modules[Object.keys(modules)[selectedSubSection]][0]
|
||||
)
|
||||
const [elem, setElem] = useState(modules[module_keys[selectedSubSection]][0])
|
||||
|
||||
const changePage = (subSectionIndex, node) => {
|
||||
setElem(node)
|
||||
@ -34,7 +34,7 @@ export default function MarkdownList({ pageContext }) {
|
||||
|
||||
const changeSubsection = (index) => {
|
||||
setSelectedSubSection(index)
|
||||
setElem(modules[Object.keys(modules)[index]][0])
|
||||
setElem(modules[module_keys[index]][0])
|
||||
}
|
||||
|
||||
return (
|
||||
@ -49,9 +49,7 @@ export default function MarkdownList({ pageContext }) {
|
||||
<main className={styles.wrapper}>
|
||||
<aside className={styles.sidebar}>
|
||||
<nav className={sidebarStyles.sidebar}>
|
||||
{Object.keys(modules)
|
||||
.sort()
|
||||
.map((ele, subSectionIndex) => {
|
||||
{module_keys.map((ele, subSectionIndex) => {
|
||||
return selectedSubSection === subSectionIndex ? (
|
||||
<div key={subSectionIndex}>
|
||||
<h4 className={sidebarStyles.groupTitle}>
|
||||
@ -71,9 +69,7 @@ export default function MarkdownList({ pageContext }) {
|
||||
: sidebarStyles.link
|
||||
}
|
||||
key={node.id}
|
||||
onClick={() =>
|
||||
changePage(subSectionIndex, node)
|
||||
}
|
||||
onClick={() => changePage(subSectionIndex, node)}
|
||||
>
|
||||
<a
|
||||
style={{
|
||||
|
Loading…
Reference in New Issue
Block a user