Skip to content

SD-2508 - fix: toc not being displayed inside w:sdt#2850

Merged
caio-pizzol merged 7 commits into
mainfrom
gabriel/sd-2508-bug-docpartobj-sdt-handler-drops-tables
May 6, 2026
Merged

SD-2508 - fix: toc not being displayed inside w:sdt#2850
caio-pizzol merged 7 commits into
mainfrom
gabriel/sd-2508-bug-docpartobj-sdt-handler-drops-tables

Conversation

@chittolinag

@chittolinag chittolinag commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Issue

Documents with a TOC inside a w:sdt whose docPartGallery is not exactly "Table of Contents" (e.g. "Custom Table of Contents") have the TOC dropped on render.

The field preprocessor converts TOC field codes (w:fldChar begin/end) into a single sd:tableOfContents element regardless of the gallery type. This means the PM documentPartObject node for any custom TOC gallery ends up with a tableOfContents child.

handleDocumentPartObjectNode dispatches on docPartGallery === 'Table of Contents' for the processTocChildren path. For any other gallery string it falls to an else-if loop that only handled paragraph children — tableOfContents children were silently dropped.

Proposed solution

Add a tableOfContents branch to the else-if loop in document-part-object.ts that forwards to the existing processTocChildren helper. No changes to the import handler or preprocessing pipeline.

Side notes

This PR fixes the issue where the TOC is completely dropped and doesn't show up in the document. However, there are still rendering issues with the TOC. This other PR is open and fixes the rendering issue.

@linear

linear Bot commented Apr 16, 2026

Copy link
Copy Markdown

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@chittolinag chittolinag marked this pull request as ready for review April 16, 2026 18:48

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad510e09aa

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/layout-engine/pm-adapter/src/sdt/document-part-object.ts Outdated
…SDTs

Word stores TOC field codes on the child tableOfContents node, not the
wrapper SDT. The new branch was passing the wrapper's tocInstruction,
which is undefined for Custom TOC docs, silently dropping per-TOC
options like '\o "1-3"'. Mirror processTocChildren's existing recursion
(toc.ts:162-172) and prefer the child's instruction.

Adds 3 unit tests for the new branch covering instruction preference,
fallback to the wrapper, and the Array.isArray guard.

@caio-pizzol caio-pizzol left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @chittolinag! loaded the customer's "Custom Table of Contents" doc against your branch and the TOC entries render now :)

i pushed a follow-up commit (56377a1) with the missing child-instruction handling and 3 unit tests for the new branch.

two things still open, both inline.

Comment thread packages/layout-engine/pm-adapter/src/sdt/document-part-object.ts
Comment thread packages/layout-engine/pm-adapter/src/sdt/document-part-object.ts Outdated
@harbournick

Copy link
Copy Markdown
Collaborator

@artem-harbour mind doing a review on this one pls?

@harbournick

Copy link
Copy Markdown
Collaborator

@chittolina pls resolve merge conflicts

@chittolinag chittolinag requested a review from a team as a code owner May 1, 2026 13:21
@chittolinag chittolinag requested a review from caio-pizzol May 1, 2026 13:22
Comment thread packages/layout-engine/pm-adapter/src/sdt/document-part-object.ts Outdated
@chittolinag chittolinag requested a review from artem-harbour May 4, 2026 20:15

@artem-harbour artem-harbour left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@artem-harbour

Copy link
Copy Markdown
Contributor

@caio-pizzol, please check your comments and let us know if this is ready for merge.

@caio-pizzol caio-pizzol left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @chittolinag! thanks for addressing last round - approving.

left one small thing inline if you want to tidy it up, but nothing blocking.

Comment thread packages/layout-engine/pm-adapter/src/sdt/document-part-object.ts
@caio-pizzol caio-pizzol merged commit 49ab1af into main May 6, 2026
71 checks passed
@caio-pizzol caio-pizzol deleted the gabriel/sd-2508-bug-docpartobj-sdt-handler-drops-tables branch May 6, 2026 14:02
@superdoc-bot

superdoc-bot Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in @superdoc-dev/mcp v0.3.0-next.62

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in @superdoc-dev/react v1.2.0-next.104

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in vscode-ext v2.3.0-next.106

@superdoc-bot

superdoc-bot Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in superdoc-cli v0.8.0-next.78

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in superdoc v1.30.0-next.60

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in superdoc-sdk v1.8.0-next.60

@superdoc-bot

superdoc-bot Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in superdoc-cli v0.9.0

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in superdoc v1.32.0

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in @superdoc-dev/mcp v0.4.0

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in @superdoc-dev/react v1.3.0

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in vscode-ext v2.4.0

@superdoc-bot

superdoc-bot Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in superdoc-sdk v1.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants