Skip to content

[Bug]: Custom Node child rendering broken in @Storyblok/richtext@^4.2.0 #610

@nianiam

Description

@nianiam

Package

@storyblok/richtext

Bug Description

When using a custom node, #565 appears to have broken the rendering of children of that node in React.

Steps to Reproduce

Create a custom Node in React:

import { StoryblokServerRichText, asTag } from '@storyblok/react/rsc';
import ParagraphExtension from '@tiptap/extension-paragraph';

const ParagraphNode = ParagraphExtension.extend({
    content: 'inline*',
    renderHTML({ node }) {
        const textAlign = node.attrs.textAlign;
        return [asTag(Typography), { textAlign, wordBreak: 'break-word' }, 0];
    },
});

const RichText = ({ doc }: { doc: StoryblokRichtext }) => {
    return (
        <StoryblokServerRichText
            doc={doc}
            tiptapExtensions={{
                paragraph: ParagraphNode,
            }}
        />
    );
};

The element is rendered, but the children are not.


Patching this fixes the problem:

diff --git a/dist/index.mjs b/dist/index.mjs
index fb36a9b40110afb2f665b0b8b91054ceaa39f3bb..b0a963f38cf1e98cc286fd34cef08a5726453986 100644
--- a/dist/index.mjs
+++ b/dist/index.mjs
@@ -924,7 +924,7 @@ function richTextResolver(options = {}) {
 				key: `${tag}-${currentCount}`
 			};
 		}
-		if (isExternalRenderFn && typeof tag !== "string" && children !== void 0) return renderFn(tag, attrs, (() => children));
+		if (isExternalRenderFn && typeof tag !== "string" && children !== void 0) return renderFn(tag, attrs, children);
 		return renderFn(tag, attrs, children);
 	};
 	/** Renders a group of text nodes with shared marks wrapped once around unique-mark content. */

Reproduction URL

No response

Expected Behavior

Children are rendered.

Actual Behavior

Children are not rendered,

Environment

System:
    OS: macOS 26.4.1
    CPU: (15) arm64 Apple M5 Pro
    Memory: 102.86 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.14.1 - /Users/mat.niania/.local/state/fnm_multishells/5097_1778753197063/bin/node
    Yarn: 1.22.22 - /Users/mat.niania/.local/state/fnm_multishells/5097_1778753197063/bin/yarn
    npm: 11.11.0 - /Users/mat.niania/.local/state/fnm_multishells/5097_1778753197063/bin/npm
    pnpm: 10.33.0 - /Users/mat.niania/.local/state/fnm_multishells/5097_1778753197063/bin/pnpm
  Browsers:
    Chrome: 148.0.7778.168
    Firefox: 150.0.3
    Safari: 26.4
  npmPackages:
    @storyblok/js: ^5.1.5 => 5.1.5
    @storyblok/react: ^6.1.6 => 6.1.6
    next: 16.2.6 => 16.2.6
    react: 19.2.5 => 19.2.5
    storyblok: ^4.16.8 => 4.16.8

Error Logs

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions