Skip to content

Storybook: Add Story for InnerBlocks - #68651

Merged
im3dabasia merged 5 commits into
WordPress:trunkfrom
dhruvikpatel18:add/inner-blocks-story
Aug 14, 2026
Merged

Storybook: Add Story for InnerBlocks#68651
im3dabasia merged 5 commits into
WordPress:trunkfrom
dhruvikpatel18:add/inner-blocks-story

Conversation

@dhruvikpatel18

@dhruvikpatel18 dhruvikpatel18 commented Jan 14, 2025

Copy link
Copy Markdown
Member

What?

This PR will add story for InnerBlocks component in the Storybook.

Why?

Part of: #67165
Part of: #22891

Testing Instructions

  1. Run npm run storybook:dev
  2. Open the storybook on localhost
  3. Check the innerBlock story.

Screenshots or screencast

innerBlocks.Screencast.mov

@Mamaduka Mamaduka added [Type] Developer Documentation Documentation for developers Storybook Storybook and its stories for components labels Jan 14, 2025
@dhruvikpatel18 dhruvikpatel18 changed the title Storybook: Add Story for innerBlock component Storybook: Add Story for innerBlocks Jan 14, 2025
@dhruvikpatel18 dhruvikpatel18 changed the title Storybook: Add Story for innerBlocks Storybook: Add Story for InnerBlocks Jan 14, 2025
@dhruvikpatel18
dhruvikpatel18 marked this pull request as ready for review January 15, 2025 05:07
@github-actions

github-actions Bot commented Jan 15, 2025

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dhruvikpatel18 <dhruvik18@git.wordpress.org>
Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions Bot added the [Package] Block editor /packages/block-editor label Aug 11, 2026

@im3dabasia im3dabasia 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.

Thanks @dhruvikpatel18

Left a few feedbacks. Please address them.

// `InnerBlocks` only renders within a block, so the props being demonstrated
// are passed down to the block type registered below through a context rather
// than rendered by the story directly.
const InnerBlocksProps = createContext( {} );

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.

InnerBlocksProps reads like the real exported useInnerBlocksProps API. Could you rename it to something like ArgsContext so the two don't get confused?

},
argTypes: {
allowedBlocks: {
control: { type: 'object' },

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.

An object control can't take true/false, so two of the three modes your own description lists aren't reachable from Controls.

A select + mapping like you did for renderAppender would cover all three, wdyt?

description:
'A component rendered in front of the appender, which can be used to represent an example state before any block is inserted.',
table: {
type: { summary: 'Component' },

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.

placeholder is rendered as a node, not invoked (block-list/index.js:281),

Navigation passes an element (inner-blocks.js:60). 'Element' fits better than 'Component'.

Comment on lines +182 to +200
export const Default = {
render: function Template( args ) {
const blocks = useContainerBlock();

return (
<InnerBlocksProps.Provider value={ args }>
<ExperimentalBlockEditorProvider
value={ blocks }
selection={ SELECTION }
>
<style>{ storyStyles }</style>
<div className="inner-blocks-story">
<BlockList />
</div>
</ExperimentalBlockEditorProvider>
</InnerBlocksProps.Provider>
);
},
};

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.

With sourceState: 'shown', the snippet is all story scaffolding, <InnerBlocks /> and the args never appear, so the source panel teaches nothing. Could you add a hand-written parameters.docs.source.code?

@im3dabasia im3dabasia 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 ✅

Works just fine

image

@im3dabasia
im3dabasia enabled auto-merge (squash) August 14, 2026 11:58
@im3dabasia
im3dabasia merged commit 0e92e54 into WordPress:trunk Aug 14, 2026
42 checks passed
@github-actions github-actions Bot added this to the Gutenberg 23.9 milestone Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor Storybook Storybook and its stories for components [Type] Developer Documentation Documentation for developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants