Skip to content

Storybook: Upgrade Storybook to 10.4#77382

Merged
aduth merged 23 commits into
trunkfrom
update/storybook-10-3
Jun 17, 2026
Merged

Storybook: Upgrade Storybook to 10.4#77382
aduth merged 23 commits into
trunkfrom
update/storybook-10-3

Conversation

@aduth

@aduth aduth commented Apr 15, 2026

Copy link
Copy Markdown
Member

What?

Updates Storybook to the latest version (10.4.3 at time of writing).

Why?

As identified in #77112, current component manifests produce incorrect results. One of the proposed action items there was to explore whether newer versions of Storybook and its related dependencies improve the outcome without workarounds like proposed in that pull request.

Additionally, this is also just general good code health maintenance to keep up to date with the latest features and bug fixes. Of note, Storybook 10.3 includes stable support for its MCP feature (which we indirectly leverage through the componentsManifest feature) as well as general accessibility improvements. Storybook 10.4 introduces a new, faster, more accurate "component meta" docgen tool which benefits the manifest.

For the manifests (which, in turn, are used by @wordpress/design-system-mcp) the difference is notable:

Hosted: https://wordpress.github.io/gutenberg/manifests/components.json
Local: storybook/build/manifests/components.json

Metric Hosted New Δ Hosted% New% Δ%
Components 63 63 0
With description 48 56 +8 76.2% 88.9% +12.7
With prop data 39 59 +20 61.9% 93.7% +31.7
Total props 245 664 +419
Props with description 215 593 +378 87.8% 89.3% +1.6

Missing descriptions and prop details are particularly problematic for the MCP server, which relays this information to AI agents to ensure the agents understand appropriateness of a component and how it should be used. Increasing the availability of descriptions for parity with how these components are documented through the live Storybook site improves the reliability of these tools.

Full details with script (AI assisted)

Descriptions gained (8)

  • ../packages/components/src/confirm-dialog/stories/index.story.tsx:ConfirmDialog
    ConfirmDialog is built of top of [Modal](/packages/components/src/modal/REA…
  • ../packages/components/src/dropdown/stories/index.story.tsx:Dropdown
    Renders a button that opens a floating content modal when clicked. ```jsx impor…
  • ../packages/components/src/popover/stories/index.story.tsx:Popover
    Popover renders its content in a floating modal. If no explicit anchor is pas…
  • ../packages/components/src/base-control/stories/index.story.tsx:BaseControl
    BaseControl is a low-level component used to generate labels and help text fo…
  • ../packages/components/src/toggle-group-control/stories/index.story.tsx:ToggleGroupControl
    ToggleGroupControl is a form component that lets users choose options represe…
  • ../packages/components/src/truncate/stories/index.story.tsx:Truncate
    Truncate is a typography primitive that trims text content. For almost all ca…
  • ../packages/components/src/scroll-lock/stories/index.story.tsx:ScrollLock
    ScrollLock is a content-free React component for declaratively preventing scrol…
  • ../packages/components/src/item-group/stories/index.story.tsx:ItemGroup
    ItemGroup displays a list of Items grouped and styled together. ```jsx impo…

Props gained (42)

  • ../packages/components/src/button/stories/index.story.tsx:Button: __next40pxDefaultSize, accessibleWhenDisabled, children, description, icon, iconPosition, iconSize, isBusy, isDestructive, isPressed (+11 more)
  • ../packages/components/src/menu-item/stories/index.story.tsx:MenuItem: isDestructive, className, children, info, icon, iconPosition, isSelected, shortcut, role, suffix (+1 more)
  • ../packages/components/src/panel/stories/index.story.tsx:Panel: ref, key
  • ../packages/components/src/progress-bar/stories/index.story.tsx:ProgressBar: value, className
  • ../packages/components/src/snackbar/stories/index.story.tsx:Snackbar: children, className, onRemove, onDismiss, listRef, as
  • ../packages/components/src/tree-grid/stories/index.story.tsx:TreeGrid: applicationAriaLabel, children
  • ../packages/components/src/confirm-dialog/stories/index.story.tsx:ConfirmDialog: children, onConfirm, confirmButtonText, cancelButtonText, onCancel, isOpen, isBusy
  • ../packages/components/src/dropdown/stories/index.story.tsx:Dropdown: as
  • ../packages/components/src/modal/stories/index.story.tsx:Modal: ref, key
  • ../packages/components/src/popover/stories/index.story.tsx:Popover: animate, children, variant, anchor, shift, inline, position, offset, onClose, resize (+15 more)
  • ../packages/components/src/tooltip/stories/index.story.tsx:Tooltip: ref, key
  • ../packages/components/src/base-control/stories/index.story.tsx:BaseControl: __nextHasNoMarginBottom, id, help, label, hideLabelFromVision, className, children, as
  • ../packages/components/src/checkbox-control/stories/index.story.tsx:CheckboxControl: help, __nextHasNoMarginBottom, disabled, onChange, label, checked, indeterminate, heading
  • ../packages/components/src/color-indicator/stories/index.story.tsx:ColorIndicator: colorValue
  • ../packages/components/src/color-palette/stories/index.story.tsx:ColorPalette: onChange, selectedSlug, clearable, colors, disableCustomColors, enableAlpha, headingLevel, value, asButtons, loop (+4 more)
  • ../packages/components/src/combobox-control/stories/index.story.tsx:ComboboxControl: label, className, help, __nextHasNoMarginBottom, hideLabelFromVision
  • ../packages/components/src/drop-zone/stories/index.story.tsx:DropZone: className, label, onDrop, onFilesDrop, onHTMLDrop
  • ../packages/components/src/form-file-upload/stories/index.story.tsx:FormFileUpload: __next40pxDefaultSize, accept, children, icon, onChange, onClick, render
  • ../packages/components/src/form-token-field/stories/index.story.tsx:FormTokenField: autoCapitalize, className, autoComplete
  • ../packages/components/src/gradient-picker/stories/index.story.tsx:GradientPicker: aria-label, aria-labelledby
  • ../packages/components/src/input-control/stories/index.story.tsx:InputControl: label, disabled, prefix, __next40pxDefaultSize, size, suffix, hideLabelFromVision, __next36pxDefaultSize, __shouldNotWarnDeprecated36pxSize, __unstableInputWidth (+13 more)
  • ../packages/components/src/number-control/stories/index.story.tsx:NumberControl: label, disabled, prefix, onChange, onDrag, onDragEnd, onDragStart, __next40pxDefaultSize, size, suffix (+23 more)
  • ../packages/components/src/radio-control/stories/index.story.tsx:RadioControl: label, help, hideLabelFromVision, disabled, onChange, options, selected
  • ../packages/components/src/range-control/stories/index.story.tsx:RangeControl: help, __nextHasNoMarginBottom, hideLabelFromVision, min, max, value, disabled, marks, step, afterIcon (+23 more)
  • ../packages/components/src/search-control/stories/index.story.tsx:SearchControl: value, help, __next40pxDefaultSize, __nextHasNoMarginBottom, onChange, onClose, onDrag, onDragStart, onDragEnd
  • ../packages/components/src/select-control/stories/index.story.tsx:SelectControl: label, disabled, prefix, __next40pxDefaultSize, size, suffix, hideLabelFromVision, __next36pxDefaultSize, __shouldNotWarnDeprecated36pxSize, labelPosition (+9 more)
  • ../packages/components/src/text-control/stories/index.story.tsx:TextControl: label, className, help, __nextHasNoMarginBottom, hideLabelFromVision, onChange, value, type, __next40pxDefaultSize
  • ../packages/components/src/textarea-control/stories/index.story.tsx:TextareaControl: label, help, __nextHasNoMarginBottom, hideLabelFromVision, onChange, value, rows
  • ../packages/components/src/toggle-control/stories/index.story.tsx:ToggleControl: disabled, checked, className, __nextHasNoMarginBottom, help, label, onChange
  • ../packages/components/src/toggle-group-control/stories/index.story.tsx:ToggleGroupControl: help, __nextHasNoMarginBottom, label, hideLabelFromVision, isAdaptiveWidth, isBlock, isDeselectable, onChange, value, children (+3 more)
  • ../packages/components/src/tree-select/stories/index.story.tsx:TreeSelect: label, children, disabled, prefix, __next40pxDefaultSize, size, variant, suffix, help, __nextHasNoMarginBottom (+5 more)
  • ../packages/components/src/unit-control/stories/index.story.tsx:UnitControl: size, onChange, isUnitSelectTabbable, units, label, disabled, value, prefix, onFocus, onBlur (+28 more)
  • ../packages/components/src/truncate/stories/index.story.tsx:Truncate: ellipsis, ellipsizeMode, limit, numberOfLines, children, as
  • ../packages/components/src/composite/stories/index.story.tsx:Composite: activeId, defaultActiveId, setActiveId, render, focusable, accessibleWhenDisabled, onFocusVisible, children
  • ../packages/components/src/disabled/stories/index.story.tsx:Disabled: children, as
  • ../packages/components/src/resizable-box/stories/index.story.tsx:ResizableBox: as, style, className, grid, snap, snapGap, bounds, boundsByDirection, size, minWidth (+20 more)
  • ../packages/components/src/slot-fill/stories/index.story.tsx:Slot: name, fillProps, bubblesVirtually, children, className, style, as
  • ../packages/components/src/form-toggle/stories/index.story.tsx:FormToggle: checked, disabled, onChange
  • ../packages/components/src/item-group/stories/index.story.tsx:ItemGroup: isBordered, isRounded, isSeparated, size, children, as
  • ../packages/ui/src/collapsible/stories/index.story.tsx:Collapsible.Root: open, defaultOpen, onOpenChange, disabled
  • ../packages/ui/src/link/stories/index.story.tsx:Link: className, render, style
  • ../packages/ui/src/tabs/stories/index.story.tsx:Tabs.Root: defaultValue, value, orientation, onValueChange

Props lost (regressions) (1)

  • ../packages/components/src/popover/stories/index.story.tsx:Popover: name

Prop count changed (42)

  • ../packages/components/src/button/stories/index.story.tsx:Button: 8 → 29
  • ../packages/components/src/menu-item/stories/index.story.tsx:MenuItem: 0 → 11
  • ../packages/components/src/panel/stories/index.story.tsx:Panel: 3 → 5
  • ../packages/components/src/progress-bar/stories/index.story.tsx:ProgressBar: 0 → 2
  • ../packages/components/src/snackbar/stories/index.story.tsx:Snackbar: 5 → 11
  • ../packages/components/src/tree-grid/stories/index.story.tsx:TreeGrid: 3 → 5
  • ../packages/components/src/confirm-dialog/stories/index.story.tsx:ConfirmDialog: 0 → 7
  • ../packages/components/src/dropdown/stories/index.story.tsx:Dropdown: 14 → 15
  • ../packages/components/src/modal/stories/index.story.tsx:Modal: 21 → 23
  • ../packages/components/src/popover/stories/index.story.tsx:Popover: 1 → 25
  • ../packages/components/src/tooltip/stories/index.story.tsx:Tooltip: 8 → 10
  • ../packages/components/src/base-control/stories/index.story.tsx:BaseControl: 0 → 8
  • ../packages/components/src/checkbox-control/stories/index.story.tsx:CheckboxControl: 0 → 8
  • ../packages/components/src/color-indicator/stories/index.story.tsx:ColorIndicator: 0 → 1
  • ../packages/components/src/color-palette/stories/index.story.tsx:ColorPalette: 0 → 14
  • ../packages/components/src/combobox-control/stories/index.story.tsx:ComboboxControl: 12 → 17
  • ../packages/components/src/drop-zone/stories/index.story.tsx:DropZone: 2 → 7
  • ../packages/components/src/form-file-upload/stories/index.story.tsx:FormFileUpload: 1 → 8
  • ../packages/components/src/form-token-field/stories/index.story.tsx:FormTokenField: 25 → 28
  • ../packages/components/src/gradient-picker/stories/index.story.tsx:GradientPicker: 12 → 14
  • ../packages/components/src/input-control/stories/index.story.tsx:InputControl: 1 → 24
  • ../packages/components/src/number-control/stories/index.story.tsx:NumberControl: 0 → 33
  • ../packages/components/src/radio-control/stories/index.story.tsx:RadioControl: 0 → 7
  • ../packages/components/src/range-control/stories/index.story.tsx:RangeControl: 0 → 33
  • ../packages/components/src/search-control/stories/index.story.tsx:SearchControl: 4 → 13
  • ../packages/components/src/select-control/stories/index.story.tsx:SelectControl: 0 → 19
  • ../packages/components/src/text-control/stories/index.story.tsx:TextControl: 0 → 9
  • ../packages/components/src/textarea-control/stories/index.story.tsx:TextareaControl: 0 → 7
  • ../packages/components/src/toggle-control/stories/index.story.tsx:ToggleControl: 0 → 7
  • ../packages/components/src/toggle-group-control/stories/index.story.tsx:ToggleGroupControl: 0 → 13
  • ../packages/components/src/tree-select/stories/index.story.tsx:TreeSelect: 4 → 19
  • ../packages/components/src/unit-control/stories/index.story.tsx:UnitControl: 0 → 38
  • ../packages/components/src/truncate/stories/index.story.tsx:Truncate: 0 → 6
  • ../packages/components/src/composite/stories/index.story.tsx:Composite: 7 → 15
  • ../packages/components/src/disabled/stories/index.story.tsx:Disabled: 1 → 3
  • ../packages/components/src/resizable-box/stories/index.story.tsx:ResizableBox: 4 → 34
  • ../packages/components/src/slot-fill/stories/index.story.tsx:Slot: 0 → 7
  • ../packages/components/src/form-toggle/stories/index.story.tsx:FormToggle: 0 → 3
  • ../packages/components/src/item-group/stories/index.story.tsx:ItemGroup: 0 → 6
  • ../packages/ui/src/collapsible/stories/index.story.tsx:Collapsible.Root: 4 → 8
  • ../packages/ui/src/link/stories/index.story.tsx:Link: 4 → 7
  • ../packages/ui/src/tabs/stories/index.story.tsx:Tabs.Root: 4 → 8

Prop descriptions gained (7)

  • ../packages/components/src/snackbar/stories/index.story.tsx:Snackbar: spokenMessage, politeness, actions, icon, explicitDismiss
  • ../packages/components/src/tree-grid/stories/index.story.tsx:TreeGrid: onExpandRow, onCollapseRow, onFocusRow
  • ../packages/components/src/drop-zone/stories/index.story.tsx:DropZone: icon, isEligible
  • ../packages/components/src/form-file-upload/stories/index.story.tsx:FormFileUpload: multiple
  • ../packages/components/src/search-control/stories/index.story.tsx:SearchControl: label, placeholder, hideLabelFromVision, size
  • ../packages/components/src/composite/stories/index.story.tsx:Composite: focusLoop, focusWrap, focusShift, virtualFocus, orientation, rtl, disabled
  • ../packages/components/src/disabled/stories/index.story.tsx:Disabled: isDisabled

Script:

#!/usr/bin/env node
/**
 * Compare a freshly built components manifest against the one currently
 * hosted at `wordpress.github.io/gutenberg/manifests/components.json`,
 * to evaluate how much the upgraded prop extractor recovers compared
 * to what's live today.
 *
 * Usage:
 *   node storybook/scripts/compare-with-hosted-manifest.mjs [path]
 *
 * The local manifest defaults to `storybook/build/manifests/components.json`.
 * The hosted manifest is read from `reactDocgen` (Storybook 10.2 shape).
 * The local manifest is read from `reactComponentMeta` (Storybook 10.4),
 * so the comparison reflects the real engine output rather than the
 * synthesized legacy field added by `inject-legacy-docgen.mjs`.
 *
 * Intended as a one-shot validation aid. Not wired into any build.
 */
import { readFile } from 'node:fs/promises';

const HOSTED_URL =
	'https://wordpress.github.io/gutenberg/manifests/components.json';
const LOCAL_PATH =
	process.argv[ 2 ] ?? 'storybook/build/manifests/components.json';

function getDocgen( component, legacy ) {
	if ( legacy ) {
		return component.reactDocgen;
	}
	return component.reactComponentMeta;
}

function getProps( component, legacy ) {
	return getDocgen( component, legacy )?.props ?? {};
}

function descriptionFor( component, legacy ) {
	return (
		component.description ||
		getDocgen( component, legacy )?.description ||
		''
	).trim();
}

function propDescriptionCount( props ) {
	return Object.values( props ).filter( ( p ) =>
		( p.description ?? '' ).trim()
	).length;
}

function summarize( label, components, legacy ) {
	const entries = Object.values( components );
	let withDescription = 0;
	let withProps = 0;
	let totalProps = 0;
	let propsWithDescription = 0;
	for ( const component of entries ) {
		if ( descriptionFor( component, legacy ) ) {
			withDescription += 1;
		}
		const props = getProps( component, legacy );
		const propCount = Object.keys( props ).length;
		if ( propCount > 0 ) {
			withProps += 1;
		}
		totalProps += propCount;
		propsWithDescription += propDescriptionCount( props );
	}
	return {
		label,
		total: entries.length,
		withDescription,
		withProps,
		totalProps,
		propsWithDescription,
	};
}

function formatSummary( old, fresh ) {
	const rows = [
		[ 'Components', old.total, fresh.total ],
		[ 'With description', old.withDescription, fresh.withDescription ],
		[ 'With prop data', old.withProps, fresh.withProps ],
		[ 'Total props', old.totalProps, fresh.totalProps ],
		[
			'Props with description',
			old.propsWithDescription,
			fresh.propsWithDescription,
		],
	];
	const colWidth = 24;
	const lines = [
		`${ 'Metric'.padEnd( colWidth ) }${ 'Hosted'.padStart(
			10
		) }${ 'New'.padStart( 10 ) }${ 'Δ'.padStart( 10 ) }`,
		'-'.repeat( colWidth + 30 ),
	];
	for ( const [ name, a, b ] of rows ) {
		const delta = b - a;
		const sign = delta > 0 ? '+' : '';
		lines.push(
			`${ name.padEnd( colWidth ) }${ String( a ).padStart(
				10
			) }${ String( b ).padStart( 10 ) }${ ( sign + delta ).padStart(
				10
			) }`
		);
	}
	return lines.join( '\n' );
}

function indexByKey( components ) {
	const result = new Map();
	for ( const component of Object.values( components ) ) {
		const key = `${ component.path }:${ component.name }`;
		result.set( key, component );
	}
	return result;
}

function diffPerComponent( oldIndex, newIndex ) {
	const findings = {
		descriptionGained: [],
		descriptionLost: [],
		descriptionChanged: [],
		propsGained: [],
		propsLost: [],
		propsCountChanged: [],
		propDescriptionsGained: [],
		propDescriptionsLost: [],
	};

	for ( const [ key, fresh ] of newIndex ) {
		const old = oldIndex.get( key );
		if ( ! old ) {
			continue;
		}
		const oldDesc = descriptionFor( old, true );
		const newDesc = descriptionFor( fresh, false );
		if ( ! oldDesc && newDesc ) {
			findings.descriptionGained.push( { key, newDesc } );
		} else if ( oldDesc && ! newDesc ) {
			findings.descriptionLost.push( { key, oldDesc } );
		} else if ( oldDesc && newDesc && oldDesc !== newDesc ) {
			findings.descriptionChanged.push( { key, oldDesc, newDesc } );
		}

		const oldProps = getProps( old, true );
		const newProps = getProps( fresh, false );
		const oldNames = new Set( Object.keys( oldProps ) );
		const newNames = new Set( Object.keys( newProps ) );
		const added = [ ...newNames ].filter( ( n ) => ! oldNames.has( n ) );
		const removed = [ ...oldNames ].filter( ( n ) => ! newNames.has( n ) );
		if ( added.length ) {
			findings.propsGained.push( { key, names: added } );
		}
		if ( removed.length ) {
			findings.propsLost.push( { key, names: removed } );
		}
		if ( oldNames.size !== newNames.size ) {
			findings.propsCountChanged.push( {
				key,
				before: oldNames.size,
				after: newNames.size,
			} );
		}

		const commonProps = [ ...oldNames ].filter( ( n ) =>
			newNames.has( n )
		);
		const gainedDescriptions = [];
		const lostDescriptions = [];
		for ( const name of commonProps ) {
			const had = ( oldProps[ name ].description ?? '' ).trim();
			const has = ( newProps[ name ].description ?? '' ).trim();
			if ( ! had && has ) {
				gainedDescriptions.push( name );
			} else if ( had && ! has ) {
				lostDescriptions.push( name );
			}
		}
		if ( gainedDescriptions.length ) {
			findings.propDescriptionsGained.push( {
				key,
				names: gainedDescriptions,
			} );
		}
		if ( lostDescriptions.length ) {
			findings.propDescriptionsLost.push( {
				key,
				names: lostDescriptions,
			} );
		}
	}

	return findings;
}

function formatList( title, items, render ) {
	if ( ! items.length ) {
		return '';
	}
	return [
		'',
		`## ${ title } (${ items.length })`,
		'',
		...items.map( render ),
	].join( '\n' );
}

function truncate( text, max = 80 ) {
	const flat = text.replace( /\s+/g, ' ' );
	return flat.length > max ? `${ flat.slice( 0, max - 1 ) }…` : flat;
}

const [ hostedManifest, localRaw ] = await Promise.all( [
	fetch( HOSTED_URL ).then( ( r ) => {
		if ( ! r.ok ) {
			throw new Error( `Failed to fetch ${ HOSTED_URL }: ${ r.status }` );
		}
		return r.json();
	} ),
	readFile( LOCAL_PATH, 'utf8' ).then( JSON.parse ),
] );

const oldIndex = indexByKey( hostedManifest.components ?? {} );
const newIndex = indexByKey( localRaw.components ?? {} );

const oldOnly = [ ...oldIndex.keys() ].filter( ( k ) => ! newIndex.has( k ) );
const newOnly = [ ...newIndex.keys() ].filter( ( k ) => ! oldIndex.has( k ) );

const oldStats = summarize( 'hosted', hostedManifest.components ?? {}, true );
const newStats = summarize( 'new', localRaw.components ?? {}, false );

const findings = diffPerComponent( oldIndex, newIndex );

console.log( '# Manifest comparison' );
console.log( '' );
console.log( `Hosted: ${ HOSTED_URL }` );
console.log( `Local:  ${ LOCAL_PATH }` );
console.log( '' );
console.log( formatSummary( oldStats, newStats ) );

console.log(
	formatList(
		'Components only in hosted manifest',
		oldOnly,
		( k ) => `- ${ k }`
	)
);
console.log(
	formatList(
		'Components only in new manifest',
		newOnly,
		( k ) => `- ${ k }`
	)
);
console.log(
	formatList(
		'Descriptions gained',
		findings.descriptionGained,
		( { key, newDesc } ) => `- ${ key }\n  ${ truncate( newDesc ) }`
	)
);
console.log(
	formatList(
		'Descriptions lost (regressions)',
		findings.descriptionLost,
		( { key, oldDesc } ) => `- ${ key }\n  was: ${ truncate( oldDesc ) }`
	)
);
console.log(
	formatList(
		'Descriptions changed',
		findings.descriptionChanged,
		( { key, oldDesc, newDesc } ) =>
			`- ${ key }\n  - ${ truncate( oldDesc ) }\n  + ${ truncate(
				newDesc
			) }`
	)
);
console.log(
	formatList(
		'Props gained',
		findings.propsGained,
		( { key, names } ) =>
			`- ${ key }: ${ names.slice( 0, 10 ).join( ', ' ) }${
				names.length > 10 ? ` (+${ names.length - 10 } more)` : ''
			}`
	)
);
console.log(
	formatList(
		'Props lost (regressions)',
		findings.propsLost,
		( { key, names } ) =>
			`- ${ key }: ${ names.slice( 0, 10 ).join( ', ' ) }${
				names.length > 10 ? ` (+${ names.length - 10 } more)` : ''
			}`
	)
);
console.log(
	formatList(
		'Prop count changed',
		findings.propsCountChanged,
		( { key, before, after } ) => `- ${ key }: ${ before }${ after }`
	)
);
console.log(
	formatList(
		'Prop descriptions gained',
		findings.propDescriptionsGained,
		( { key, names } ) =>
			`- ${ key }: ${ names.slice( 0, 10 ).join( ', ' ) }${
				names.length > 10 ? ` (+${ names.length - 10 } more)` : ''
			}`
	)
);
console.log(
	formatList(
		'Prop descriptions lost (regressions)',
		findings.propDescriptionsLost,
		( { key, names } ) =>
			`- ${ key }: ${ names.slice( 0, 10 ).join( ', ' ) }${
				names.length > 10 ? ` (+${ names.length - 10 } more)` : ''
			}`
	)
);

Testing Instructions

Verify that development and built outputs produce navigable stories, preserving existing expectations of Storybook that commonly regress in upgrades like like component descriptions, prop tables, code snippets.

Use of AI Tools

Used Claude Code and Claude Opus 4.7 to upgrade, iterate and analyze regressions, and explore workarounds to restore parity of documentation and build times.

@github-actions github-actions Bot added [Package] Components /packages/components [Package] DataViews /packages/dataviews [Package] Theme /packages/theme [Package] UI /packages/ui labels Apr 15, 2026
@github-actions

github-actions Bot commented Apr 15, 2026

Copy link
Copy Markdown

Size Change: -17 B (0%)

Total Size: 8.6 MB

📦 View Changed
Filename Size Change
build/scripts/components/index.min.js 264 kB -17 B (-0.01%)

compressed-size-action

@github-actions

github-actions Bot commented Apr 15, 2026

Copy link
Copy Markdown

Flaky tests detected in 9f2be2e.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/27637900453
📝 Reported issues:

@jsnajdr

jsnajdr commented Apr 16, 2026

Copy link
Copy Markdown
Member

npm run storybook:build is painfully slow. Was it always this slow?

On my machine the old Storybook build takes 1min20s, while with this PR it goes up to 12min. Something horrible is going on. I suspect it's related to react-docgen, but will need to investigate more.

Turning off componentsManifest completely doesn't help, the timing is still the same.

@jsnajdr

jsnajdr commented Apr 16, 2026

Copy link
Copy Markdown
Member

The build times go back to normal when I disable the EXPERIMENTAL_useProjectService option for react-docgen-typescript. I.e., when I basically revert #74807 where we added this option to fix missing component props.

@jsnajdr

jsnajdr commented Apr 16, 2026

Copy link
Copy Markdown
Member

After I disable EXPERIMENTAL_useProjectService, then:

  • build times are back to normal, there is even an improvement from 80s to 50s
  • the components props bug fixed by Storybook: Fix missing props from component stories #74807 doesn't reappear, i.e., I still see full set of component props
  • there continues to be a lot of "prop type error" messages on the manifests/components page, the component descriptions are not fixed

@aduth

aduth commented Apr 16, 2026

Copy link
Copy Markdown
Member Author

Nice find, @jsnajdr 👍 Yeah, I think it's fine to disable that as long as the regression doesn't return. And it sounds like it's separate problem from the component import resolution.

@jsnajdr

jsnajdr commented Apr 17, 2026

Copy link
Copy Markdown
Member

The "Prop type error" and "No component file found" errors happen because the manifest generator fails to read the component info with react-docgen-typescript. It reads the root tsconfig.json and there the file array files: [] is empty. The tsconfig.json loads successfully, the file path to read is also right, there are no problems with process.cwd, it's just that the TypeScript program project is empty. Everything is in project references, but these are ignored.

The storybookjs/storybook#34386 issue is very closely related. The reporter has the same problem, and tried to work around by creating a custom tsconfig.storybook.json that lists all the monorepo files directly. But then hit another bug, where the manifest generator ignores the custom tsconfig file.

This is a problem only in the manifest generator, which is quite independent from the main storybook build. There, when generating the stories for components and their props docs, react-docgen-typescript is also called, but slightly differently: there the TypeScript program is "synthetic", not based on tsconfig.json, and always includes just the one file to parse.

At this moment I don't know how to solve this, it will probably require an upstream patch.

@aduth

aduth commented Apr 17, 2026

Copy link
Copy Markdown
Member Author

Nice discovery @jsnajdr . I had also stumbled on storybookjs/storybook#34386 but wasn't entirely confident it was related. It was also the reason I added the commented tsconfigPath configuration, though I guess as you mention this wouldn't be properly respected anyways.

I wonder if there's some option to temporarily patch/override tsconfig.json as part of the build to configure it as Storybook would expect 🙈 We've certainly done similar things before, though it feels very hacky and error-prone.

@jsnajdr

jsnajdr commented Apr 17, 2026

Copy link
Copy Markdown
Member

I wonder if there's some option to temporarily patch/override tsconfig.json as part of the build to configure it as Storybook would expect

The main problem is that the manifest generator code is almost completely independent from the rest of Storybook, and does things its own way. And it's a very new code (2 months old) that is not battle-tested.

The main Storybook build uses react-docgen-typescript through the vite-plugin-react-docgen-typescript plugin that's part of the Vite framework preset. If you look at the plugin code:

https://github.com/joshwooding/vite-plugin-react-docgen-typescript/blob/main/packages/vite-plugin-react-docgen-typescript/src/index.ts

you can see it does a tremendous amount of preprocessing and wrapping before actually creating the docgen instance with docGen.withCompilerOptions. There is the resolveTypescriptProject function that reads the tsconfig.json and then manually resolves all the references and child tsconfig.jsons.

The manifest generator doesn't reuse this at all, it has its own code to load the TS project and create the docgen instance. It's much simpler, but doesn't work for our case.

@aduth aduth force-pushed the update/storybook-10-3 branch from 72955b0 to 336edb4 Compare May 27, 2026 20:11
aduth added a commit that referenced this pull request May 27, 2026
Opt into Storybook 10.4's `experimentalReactComponentMeta` feature, which
backs the components manifest with a persistent TypeScript LanguageService
(via `@volar/typescript`). The previous manifest extractor used a bespoke
tsconfig loader that ignored `references`, so our root `tsconfig.json`
(which has `files: []` and delegates everything to references) produced an
empty TS program. The result was a manifest peppered with "No component
file found" errors, identified in #77382 and the upstream issue
storybookjs/storybook#34386.

Also drop `EXPERIMENTAL_useProjectService: true` from the
`react-docgen-typescript` options. Per investigation in #77382, this flag
was the cause of a ~10x build slowdown. Removing it does not reintroduce
the prop-extraction regression that #74807 added it to address.

The `experimentalReactComponentMeta` flag only affects the manifest
pipeline. The in-stories docs UI continues to use `react-docgen-typescript`
through the React Vite framework's Vite plugin, including our existing
`propFilter`. The new engine has its own source filtering for the manifest.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@aduth aduth changed the title Storybook: Upgrade Storybook to 10.3 Storybook: Upgrade Storybook to 10.4 May 27, 2026
@aduth

aduth commented May 27, 2026

Copy link
Copy Markdown
Member Author

I've refreshed this pull request and updated Storybook to the new latest version 10.4.1. One additional notable improvement in this new version is the availability of their new component meta extractor tool for manifests, which aims to replace react-docgen and react-docgen-typescript. Currently this is only available for manifests, but it's still very useful in how we use the manifests for the design system MCP server package. I added a detailed comparison in the original post, but a quick summary of findings:

Hosted: https://wordpress.github.io/gutenberg/manifests/components.json
Local: storybook/build/manifests/components.json

Metric Hosted New Δ
Components 63 63 0
With description 48 56 +8
With prop data 39 59 +20
Total props 245 664 +419
Props with description 215 593 +378

However, there were a lot of complications in this upgrade, some of which were already seen in the earlier attempt.

A quick summary:

  • Missing component descriptions (including regressions for some components like Button)
    • In manifests:
      • Some of this is attributable to a known upstream bug [Bug]: React Component Meta: "No component file found" for args-only CSF stories using preview.meta() + meta.story({ args }) storybookjs/storybook#34877, which is addressed here with a temporary workaround applying explicit render option for component stories
      • Some of this is related to inability to follow ref forwarding consistently. Since we're now on React 19, I chose to address components in @wordpress/components which were affected by this and which are surfaced as part of the components manifest (namely, Button).
        • I'm not sure it's safe to remove forwardRef for packages like @wordpress/ui which may be bundled into downstream plugins that support multiple versions of WordPress, but packages like @wordpress/components that are shipped through WordPress itself should be safe (i.e. this code will only ever run on WordPress 7.1, where React 19 is safely available)
    • In the Storybook front-end UI:
      • An AI analysis concluded that this was due to how, when using the base configuration, the docgen tool would detect multiple descriptions, including from built .d.ts files where the description was missing, and in resolving the duplication would pick the wrong one and drop the description. The solution is to remove references to avoid resolving these duplicate versions and only make the source component implementation code available to the TypeScript compiler.
  • Changing shape of component manifest breaking expectations in @wordpress/design-system-mcp
    • In an earlier analysis, I think I discovered that this would have happened regardless of switching to the new "meta" docgen tool, since the property we were relying on (reactDocgen) should have already been named according to the docgen tool we were using, i.e. reactDocgenTypescript) so it was going to break at some point regardless.
    • To address this, I'm adding a temporary "shim" to restore the property structure that existing consumers of @wordpress/design-system-mcp would expect to see. This means that people using an old version of the plugin will still be able to read the file once the new version becomes published at https://wordpress.github.io/gutenberg/manifests/components.json (the MCP reads directly from this URL). People using new version will also support the new property. And since the MCP server installation instructions embed @latest as part of the setup command, we should be able to expect that we can remove this shim once the updated package becomes the new latest version.

Comment on lines +131 to +135
### `ref`

- Type: `Ref<any>`
- Required: No

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Something to consider for our docgen tool now that we're on React 19 and ref looks like any other prop. Should it be documented? We didn't document it before even though we were forwarding the ref.

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.

I'm leaning more towards documenting it:

  • it's now a prop like any other, less custom code to maintain
  • not all components support ref (especially in @wordpress/components), so if we omit it, we'd be hiding that information

The question is: given we may want to add support for React 18 for some time, are we doing this migration now, or should we wait?

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.

And also, should we apply the same "fix" to other components flagged with the same issue (Navigator, ColorPicker, Slot, ...)

@aduth aduth Jun 1, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm leaning more towards documenting it:

Yeah, I tend to agree. I'll see about adding a brief description, assuming it's feasible to do so within the current types. It would probably be ideal to standardize the description, and maybe that should happen inside the API docs tool.

The question is: given we may want to add support for React 18 for some time, are we doing this migration now, or should we wait?

My understanding is that this is safe to do inside @wordpress/components or any window.wp script package, because the code that's included in these packages is linked to the version of React in WordPress (i.e. this code will be shipped with WordPress 7.1 / React 19, and older versions of wp.components shipped in earlier versions of WordPress will continue to use forwardRef).

Though it'd be good to have confirmation on this understanding. There's a few related discussions about how wpScript packages do or don't have to support React 18 (example).

And also, should we apply the same "fix" to other components flagged with the same issue (Navigator, ColorPicker, Slot, ...)

The problem with these components is different than needing to refactor forwardRef to use ref-as-prop. In fact, for most of them, the problem is that we haven't written a description at all 😅

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

And also, should we apply the same "fix" to other components flagged with the same issue (Navigator, ColorPicker, Slot, ...)

The problem with these components is different than needing to refactor forwardRef to use ref-as-prop. In fact, for most of them, the problem is that we haven't written a description at all 😅

Though it could certainly resurface for those other components, and I think the best way to address this is a pull request that mass-updates forwardRef to ref-as-prop (scoped as needed to keep things sensible).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm leaning more towards documenting it:

Yeah, I tend to agree. I'll see about adding a brief description, assuming it's feasible to do so within the current types. It would probably be ideal to standardize the description, and maybe that should happen inside the API docs tool.

Looking closer at this, the original implementation by Claude to just shove a type intersection & { ref?: Ref< any > } on the component props destructure wasn't ideal. This is a standard React prop, and we should use standard React utility types to document this, and certainly do better than any. In b889e06 I moved this to types.ts and used React.RefAttributes with the appropriate HTML element generic.

Separately, a couple thoughts:

  • Especially as we continue to refactor components, we might want to replace React.ComponentPropsWithoutRef with React.ComponentPropsWithRef so that this typing comes through WordPressComponentProps instead of per-component. The only question I have there is whether we want the explicit per-component opt-in as an indication that the component does, in fact, forward the ref (or at least does something with it).
  • Note that the changes in b889e06 will once again remove ref from README.md, despite us agreeing above that we should document it. I think this is a question for the API docs tool, which currently filters out all library types. Given this revised approach, ref is a library type, so how should we reconcile that? Do we want to make ref a special case in the props filtering?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In b889e06 I moved this to types.ts and used React.RefAttributes with the appropriate HTML element generic.

This turned out to be a bit more involved to address build errors which emerged after this change. In general, a lot of it stems from additional strictness we get going from plain forwardRef (without generic) to typed Ref values.

A few additional notes:

  • I changed from React.RefAttributes to Ref after seeing that documentation for RefAttributes discourages its use except when needing to handle compatibility with legacy refs.
    • This also brings back the README.md documentation since ref is defined in the component's own types. I added a brief description, although the same question as above still applies if we want to consider handling this centrally in the API docs tooll
  • I did a light exploration of what it looks like to convert WordPressComponentProps to use React.ComponentPropsWithRef and I think the biggest part of this work will be reconciling the handling of refs in contextConnect

@aduth aduth marked this pull request as ready for review May 27, 2026 20:38
@aduth aduth requested review from a team, ajitbohra, gigitux, ntsekouras and oandregal as code owners May 27, 2026 20:38
@github-actions

github-actions Bot commented May 27, 2026

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: aduth <aduth@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>

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

@aduth aduth added [Type] Developer Documentation Documentation for developers Storybook Storybook and its stories for components labels May 27, 2026
@aduth

aduth commented Jun 16, 2026

Copy link
Copy Markdown
Member Author
  • Most components are fine, but a few show an incorrect component name in code snippets. Menu is the only one I've seen with this. Might be something with displayName or how name is extracted in general.

This one is also rather complex, and seems to stem from a few inter-related issues:

  • Because Menu has both a default export and named export, react-docgen-typescript picks this up as two distinct documentable entries "Menu" (from component name) and "menu" (from folder name)
  • @joshwooding/vite-plugin-react-docgen-typescript has an option setDisplayName defaulting to true which sets component names through injected code. With 0.6.3, this behavior changed from setting based on the display name to the "target expression": the injected code changed from Menu.displayName = "Menu" and menu.displayName = "menu" (latter being ineffective and ignored) to Menu.displayName = "Menu" and Menu.displayName = "menu" (effectively causing code name to appear as lowercase)

A couple thoughts here:

  • Because we "set display names ourselves", I don't think we should have ever wanted setDisplayName to be true, and were just lucky it hadn't been an issue 'til now.
  • It's not clear to me that we need or want both named and default Menu exports, so another indirect solution here could be to drop the default export in favor of the named export.

I updated setDisplayName default to false in 1223483 and confirmed that it restored the correct capitalization for the Menu code snippet (screenshot). I'll double-check in my morning that this doesn't regress anywhere where we might have been relying on that behavior.

aduth and others added 23 commits June 17, 2026 10:04
Bump Storybook and related framework packages from 10.2.8 to 10.4.1.
Bump `react-docgen-typescript` from 2.2.2 to 2.4.0 (root + tools/api-docs)
to align with what Storybook 10.4's react-vite framework expects.

The `experimentalComponentsManifest` feature flag stabilized to
`componentsManifest` in Storybook 10.3, so rename it accordingly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Opt into Storybook 10.4's `experimentalReactComponentMeta` feature, which
backs the components manifest with a persistent TypeScript LanguageService
(via `@volar/typescript`). The previous manifest extractor used a bespoke
tsconfig loader that ignored `references`, so our root `tsconfig.json`
(which has `files: []` and delegates everything to references) produced an
empty TS program. The result was a manifest peppered with "No component
file found" errors, identified in #77382 and the upstream issue
storybookjs/storybook#34386.

Also drop `EXPERIMENTAL_useProjectService: true` from the
`react-docgen-typescript` options. Per investigation in #77382, this flag
was the cause of a ~10x build slowdown. Removing it does not reintroduce
the prop-extraction regression that #74807 added it to address.

The `experimentalReactComponentMeta` flag only affects the manifest
pipeline. The in-stories docs UI continues to use `react-docgen-typescript`
through the React Vite framework's Vite plugin, including our existing
`propFilter`. The new engine has its own source filtering for the manifest.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Storybook 10.3 split prop extraction output across engine-specific
manifest fields (`reactDocgen`, `reactDocgenTypescript`, and as of 10.4
`reactComponentMeta`). Deployed `@wordpress/design-system-mcp` clients
were built against the 10.2 shape and read only the legacy `reactDocgen`
field, so the manifest published to GitHub Pages needs to keep carrying
that field for old clients to continue working.

Add a post-build step that walks the built manifest and synthesizes a
`reactDocgen` entry from `reactComponentMeta` data on each component
(and subcomponent) that has one. The only field that actually has to
change is the rename from `type` to `tsType`. Everything else passes
through verbatim, which matches what the legacy field has historically
carried (`description`, `displayName`, plus engine-specific extras).

The shim is intentionally temporary. Once the next
`@wordpress/design-system-mcp` release ships with parser support for
the new shape and consumers have rolled forward through their `@latest`
npm fetch (a few weeks given the 2-week publish cadence), the shim and
its npm script wire-up can be deleted.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Storybook 10.3 split the manifest's prop extraction output into
engine-specific fields. Storybook 10.4 added `reactComponentMeta` for
its new LanguageService-backed extractor, which we now use. New clients
of this package only ever read manifests built from this codebase, so
they can target the new field directly.

Backwards compatibility for in-the-wild MCP clients still pinned to the
previous shape is handled separately by the post-build shim in
`storybook/scripts/inject-legacy-docgen.mjs`, which synthesizes a
legacy `reactDocgen` field on the published manifest.

The new shape uses `type` rather than `tsType` for prop types and has
a nullable `defaultValue`. The parser is otherwise unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This is no longer necessary with React 19. Downstream components that access components package will do so through window.wp.components, which in older versions of WordPress will continue to use forwardRef approach, so this only interacts with environments where React 19 is available.

This is needed to ensure that Storybook prop description extraction can effectively access the component's metadata, which forwardRef can interfere with.
Not seen locally, but local removal doesn't get reset on install. Might be caused by npm version difference
Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com>
routes aren't structured this way with src directory, and there are no stories here currently. This includes pattern should reflect current stories covered
Always passing the argument anyways, and the script is meant to be temporary, meaning we shouldn't optimize for cases that we don't need. The fallback is wrong because the cwd when this script is evaluated is already inside `storybook`, so `storybook/` relative path would not exist.
Defer to React to provide typings, which we previously explicitly omit through `WordPressComponentProps`
Resolves issue with Storybook docgen documentation extraction inconsistency across web and manifest versions, while maintaining named components in React DevTools. The standalone export was never used.
@aduth aduth force-pushed the update/storybook-10-3 branch from 1223483 to 20b0949 Compare June 17, 2026 14:04
@aduth

aduth commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

Testing today, I notice the code samples for compound components only show the base name and not the full compound name, but this also happens in the current version. I thought we had tried to improve this kind of issue in the past (#78184, #78212), but that might have been more for the tabs names when viewing the default "Docs" story.

Screenshot 2026-06-17 at 10 15 31 AM

@aduth

aduth commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

I did a manual smoke test between local and current live site as well as an AI-assisted check (results below), and this appears to be in good shape now 👍

AI representative sample test results

Yes — checking all 232 docs pages isn’t realistic for a human or a one-off agent pass. A representative smoke set (~10–15 components covering different docgen patterns) is the right approach, and I ran that against both:

What I tested (12 components)

Category Docs page Why
Standard control Button @ignore props, descriptions, Show code
Compound (new) Menu <Menu> vs <menu> regression
Overlay Tooltip, Modal, Popover forwardRef / overlay props
Container Tabs, Card, Flex named functions, compound subcomponents
Complex input FormTokenField, DropdownMenu large prop tables
Design System @wordpress/ui Button separate package docgen
Simple / deprecated Divider basic props (flaky on first run)

Results: local 10.4.3 vs live 10.2.8

Component Props (local / live) Prop names match Descriptions Code snippets
Button 21 / 21 all filled identical
Menu 6 / 6 all filled <Menu> (not <menu>) ✓
Tooltip 8 / 8 all filled identical
Modal 21 / 21 all filled identical
Tabs 9 / 9 all filled identical
Flex 8 / 8 all filled identical
Card 13 / 13 all filled identical
FormTokenField 22 / 22 all filled identical
DropdownMenu 15 / 15 all filled identical
DS Button 13 / 13 all filled identical
Popover 25 / 25 all filled identical
Divider 5 / 5* all filled identical

*Divider timed out on the first automated pass (iframe load flake); a retry showed 5 props and matched live.

Historical issues — status

  • @ignore props leaking__experimentalIsFocusable and describedBy are hidden on both local and live. __next40pxDefaultSize is visible on both (it’s not @ignore; it has a real description).
  • Descriptions missing0 empty descriptions across all successful pages on both versions.
  • Wrong code snippetsno regressions in the sample; Menu shows <Menu> correctly on local 10.4.3. First code snippets matched live exactly for every component checked.

No render errors on live. Local had one timeout (Divider only).

Expected 10.4 differences (not regressions)

  • Show code button / panel UX may differ (you already noted this).
  • Code may include story args like __next40pxDefaultSize in snippets — same on both versions in this sample.

@aduth aduth merged commit a62cbd3 into trunk Jun 17, 2026
40 of 44 checks passed
@aduth aduth deleted the update/storybook-10-3 branch June 17, 2026 14:59
@github-actions github-actions Bot added this to the Gutenberg 23.5 milestone Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Components /packages/components [Package] DataViews /packages/dataviews [Package] Theme /packages/theme [Package] UI /packages/ui 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.

4 participants