feat(KNO-7916): Add support for linking to Accordion components#1387
Open
feat(KNO-7916): Add support for linking to Accordion components#1387
Conversation
…ms channel data accordion
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Risk HIGH: Adds an optional anchorId prop to the shared Accordion component to support deep-linking via URL hash fragments, with two MDX files updated to use it.
Reasons
- A
.tsxfile incomponents/is modified (components/ui/Accordion.tsx), which automatically triggers HIGH risk per classification rules - The
Accordioncomponent is a shared/reusable UI component used across many documentation pages - A new React hook (
useLayoutEffect) and a global event listener (hashchange) are introduced, changing component behavior - The change is backward-compatible (the
anchorIdprop is optional and existing accordions are unaffected) - The MDX changes are minimal (link URL update + adding the new
anchorIdprop to one accordion instance)
Notes
- Verify that
useLayoutEffectdoes not cause SSR hydration warnings sincegetHashFragment()returns""on the server but may return a value on the client. Consider whetheruseEffectwould be more appropriate to avoid potential hydration mismatches. - Confirm that the
hashchangeevent listener is cleaned up correctly on unmount and that multiple accordions with differentanchorIdvalues on the same page do not conflict. - Check that the deep-link behavior works correctly when navigating between pages in the Next.js SPA (client-side routing may not fire
hashchangein all cases). - The
idattribute set on theBoxelement should be verified to not collide with any existing heading anchor IDs on the same page.
Sent by Cursor Automation: Docs PR classifier
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
Our docs rely heavily on the
Accordioncomponent to collapse content for better scannability. Currently, when we need to link to a specific accordion (rather than just the nearest heading), we can't - we can only link to a section. In pages with lots of accordions, like Setting Channel Data, this means users land on the right section but still have to hunt for the right accordion themselves.For example, in the MS Teams overview, we link to the channel data docs for MS Teams-specific requirements but we can't deep-link directly to that accordion, so users have to find it manually.
What this PR does
Adds an optional
anchorIdprop to theAccordioncomponent. When set, it assigns that value as the wrapper's DOM id and automatically opens the accordion on page load if the URL hash matches. Note that this is optional and accordions withoutanchorIdshould behave exactly as before (so there's no requirement to add it everywhere). Also, eachanchorIdmust be unique within a page, but the same value can be reused across pages.In this PR, I've only added
anchorIdto the specific example described above.Open questions for the team
anchorIdacross the docs, or just add them as we notice they'd be useful? My take is that we don't need it on every accordion but rather only where we have a stable deep link that should open a specific one. If an accordion is unlikely to be linked to directly, a heading anchor is probably enough. But open to other opinions!Accordionmake the most sense? I'm very open to other opinions here as well!Tasks
KNO-7916
Recordings
Current behavior
Screen.Recording.2026-04-10.at.10.38.12.AM.mov
New behavior
https://docs-git-rt-kno-7916-linking-to-accordions-knocklabs.vercel.app/integrations/chat/microsoft-teams/overview#how-to-set-channel-data-for-a-microsoft-teams-integration-in-knock
Screen.Recording.2026-04-10.at.10.39.24.AM.mov