Expanding a sub-chapter opens another sub-chapter
I found an edge case where expanding a sub-chapter opens another sub-chapter as well. However, I could not reproduce the behavior in all instances. Please see the video for more info.
To reproduce:
- Navigate to the API reference preview using this PR.
- Expand the Customers chapter
- Expand the Business Units chapter
- Expand the Associates sub-chapter (inside Customers)
https://github.com/commercetools/commercetools-docs-kit/assets/14042876/45f99d76-6b66-46df-82be-f2647fe90303
Linking the Foundry B2B example here for reference.
@melindafekete I had a more in depth look to the issue and the 2 cases you're pointing out as reproduction examples. There is a bug indeed, but it's not the case of both of the issues you're experiencing. Let me add some details:
- API website: In this case it's clearly a bug, the code is not differentiating between different sub chapter that are at the same level, I'm working on a fix
- Foundry website: in this case, the way in which navigation.yaml is defined is not correct, meaning that the current implementation doesn't support 2 navigation items pointing to the exact same page. if you want 2 navigation items pointing to the same content you must create 2 different pages with the same content. This is not a bug but it's the intended behaviour as we can't uniquely identify what's the correct item to expand/highlight in the navigation since both the navigation items point to the same page
Possible solutions for the Foundry site:
- Use content inclusion: the content is defined in a separate .mdx file and the included in both of the pages (pro: single content to maintain, cons: the right bar TOC is not supported)
- Duplicate the content in 2 pages. For example one can be called
b2c-project-steering.mdxandb2b-project.steering.mdx
FYI: @FFawzy
Thanks! I'll have a chat with the team, but I think given the TOC thing we'll probably have to go for duplicating the pages
Thank you @melindafekete . Have a thought also about how often this use case could happen in the future, so we could evaluate better if it's needed to invest time on the TOC generation for included content