Custom Rendered Heading in a macro does not appear in Table Of Contents

Hello,

I’m building a Confluence Forge UI Kit macro with layout: bodied.

It renders a heading from its configuration above the editable macro body, roughly like this:

import { AdfRenderer, Heading, Stack, useProductContext } from '@forge/react';

const MyMacro = () => {
  const context = useProductContext();

  return (
    <Stack>
      <Heading size="medium">My Title</Heading>
      <AdfRenderer document={context?.extension?.macro?.body} />
    </Stack>
  );
};

The heading is visible on the page, but it does not appear in the page’s Table of Contents.

Is there a supported way for a Forge macro to contribute a heading to the page’s ToC without asking the author to add a separate Confluence heading?

Thank you

Hi @RayHaddad,

No supported way for a Forge macro today. The ToC only reads headings stored in the page body, and your Heading is rendered inside the macro’s iframe so it never gets into the page ADF.

Same mechanism on CONFCLOUD-72469, where support confirmed in January that the Questions list macro’s headings don’t show up either. adfExport won’t help. Export and history only.

The one route I’d look at is the app writing a real heading into the page body via the content update API, right above the macro, once (say on config save), not on every render. Untested on our side though.

Hello @Mihai_leanzero ,

Thank you for your response.

I tried implementing the update API strategy, it worked but had a caveat.

When I update a config, then save the page, the page seems to have the old cached pre-update value instead of the fresh newly updated value.

Separately, this caching issue also occurs whenever I use useConfig() hook, is there a jira ticket for this known issue as well.

Thank you for your assistance!

Best,

Ray

Hi @RayHaddad,

Not one that names useConfig. Closest is ECO-1710: the extension context is frozen at the iframe’s first load and getContext() and useProductContext() keep serving that snapshot after an edit made elsewhere, which is roughly what a REST update does.

The save caveat matches ECO-1137. Editor keeps the old macro data. Workaround there is waiting for the macro to re-render before saving.

Neither ticket lists config itself. Unreproduced here too, so closest matches only. Vote on ECO-1710 and drop the repro there.

Which @forge/react version? The useConfig docs tie post-update values to 11.0.0 and up.