ministryofjustice / moj-frontend

Use the MoJ Design System to design, build, and deliver accessible and consistent services.
https://design-patterns.service.justice.gov.uk/
MIT License
33 stars 21 forks source link

docs(side nav): fix duplicate id issue on collapsible navs #955

Closed chrispymm closed 10 hours ago

chrispymm commented 1 day ago

Our current sidenav custom element, applies incremental ids to each collapsible item within it starting with collapsible-nav-0

If there are multiple <moj-collapsible-nav> elements on a page, each starts applying ids from 0, which results in duplicate ids on the page.

This PR fixes this issue, by applying either a dynamic, timestamp-based id to each instance of the component, or by allowing the user to manually set an id on the custom element, and using this id as a prefix for the child collapsible nav elements.