microsoft / microsoft/fluentui

[Bug]: @fluentui/react-storybook-addon has no support for raw/unattached MDX docs pages (no TOC / docs chrome)

Open
#36,368 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area: Build System Package: react-storybook-addon Type: Bug :bug:
Dominant language
TypeScript
Stars
20.3k
Forks
2.9k
Avg merge
2d 9h
Merged PRs (30d)
46

Description

Area

storybook

Environment
System:
  OS: macOS 15.7.7
Binaries:
  Node: 22.21.1
npmPackages:
  @fluentui/react-storybook-addon: 0.6.0
  storybook: 9.1.19
  @storybook/addon-docs: 9.1.19
Current Behavior

@fluentui/react-storybook-addon provides its branded docs chrome — the sticky "On this page" TOC, the theme picker, the LTR/RTL switch, and the Copy Page button — only for story-based docs pages (CSF autodocs), because that chrome lives in FluentDocsPage, which the addon registers as the global docs.page.

Raw / unattached MDX documentation pages (<Meta title="…" /> with no of= / no story) are not supported: they render their own MDX content and never go through FluentDocsPage, so they get none of the Fluent chrome — in particular no table of contents.

Storybook's own native parameters.docs.toc doesn't fill the gap either:

  • On story pages, FluentDocsPage renders its custom Toc and ignores parameters.docs.toc.
  • On raw MDX pages, the default DocsPage/DocsPageWrapper (which renders the native toc sidebar) is bypassed, so setting docs.toc (per‑<Meta> or globally) emits no TOC element at all (verified in the DOM).

So today there is no first-class way to give a long-form MDX documentation page the same "On this page" navigation (and other Fluent docs chrome) that story pages get.

Current workaround (imperfect): explicitly render the exported <TableOfContents> block inside the MDX:

import { Meta, TableOfContents } from '@storybook/addon-docs/blocks';

<Meta title="Docs/My Page" />

<TableOfContents headingSelector="h2, h3" title="On this page" contentsSelector=".sbdocs-content" />

It lists the headings, but because it's injected into the content flow (not a dedicated TOC column), tocbot positions it inline / at a wrong fixed offset instead of the sticky right-hand sidebar, so it doesn't match the addon's own TOC without extra custom CSS. It also doesn't bring the theme/dir/copy chrome.

Expected Behavior

@fluentui/react-storybook-addon should support raw/unattached MDX docs pages — rendering the same Fluent docs chrome for them as for story pages, most importantly a sticky "On this page" TOC generated from the MDX headings (and ideally the theme picker / LTR-RTL switch / Copy Page toggles), so MDX and story docs pages are visually and functionally consistent.

Acceptable shapes for a fix (any one):

  • FluentDocsContainer renders the Fluent TOC/chrome for unattached MDX pages (deriving the TOC from the rendered headings), or
  • the addon exports a documented block/helper (e.g. a Fluent <TableOfContents> / page wrapper) that MDX authors can drop in to get the branded sticky TOC and chrome, or
  • FluentDocsPage/container honors parameters.docs.toc so the native TOC renders in the same sidebar slot.
Reproduction

Real-world example (Storybook 9 docsite that consumes the addon): https://github.com/microsoft/fluentui-system-icons/pull/1138 — the standalone MDX pages under packages/docsite/stories/Icons/*.mdx cannot get a TOC / the Fluent docs chrome.

Minimal repro in any Storybook 9 project using @fluentui/react-storybook-addon:

  1. Add the addon (its preset sets docs.container = FluentDocsContainer and docs.page = FluentDocsPage).
  2. Add a raw/unattached MDX page (<Meta title="Docs/Repro" />) with several ##/### sections.
  3. Open the page — there is no "On this page" TOC and none of the Fluent docs chrome (theme/dir/copy). Enabling parameters.docs.toc (per‑<Meta> or globally) changes nothing.
Steps to reproduce
  1. In a Storybook 9 project, install and register @fluentui/react-storybook-addon.
  2. Create a raw/unattached MDX page (<Meta title="Docs/Repro" />) with multiple ##/### headings.
  3. Open the docs page and inspect the DOM.
  4. Observe there is no .toc-wrapper / "On this page" element and no Fluent docs chrome — raw MDX pages are unsupported.
Suggested severity

Low - Has or doesn't need a workaround

Products/sites affected

Storybook docsites consuming @fluentui/react-storybook-addon that include long-form MDX documentation pages (e.g. the https://github.com/microsoft/fluentui-system-icons docsite).

Are you willing to submit a PR to fix?

no

Validations
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the addon preset's docs.container and docs.page registrations to FluentDocsContainer and FluentDocsPage, then reproduce a raw MDX page with headings and inspect the DOM. Done means raw pages receive a stable sticky "On this page" TOC and the Fluent docs chrome without regressing story-based docs.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, storybook, typescript
Domain
documentation, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.