Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
- Update Jest type definitions to v30 ([#80767](https://github.com/WordPress/gutenberg/pull/80767)).
- `Autocomplete`: `__unstableUseAutocompleteProps` now narrows its returned ARIA props and no longer asks for a `contentRef` it never used, so callers can spread its return value onto an element without a placeholder ref, normalizing, or casting ([#80403](https://github.com/WordPress/gutenberg/pull/80403)).
- Improved performance of TypeScript types for internal polymorphic `WordPressComponent` component type ([#80364](https://github.com/WordPress/gutenberg/pull/80364)).
- Further improved `WordPressComponent` typecheck performance: intrinsic `as` values use a shared attribute bag instead of remapping props per HTML tag ([#80705](https://github.com/WordPress/gutenberg/pull/80705)).
- `ConfirmDialog`: Type the `size` prop forwarded to `Modal` ([#80705](https://github.com/WordPress/gutenberg/pull/80705)).
- `ToggleGroupControl`: Type the `disabled` prop ([#80705](https://github.com/WordPress/gutenberg/pull/80705)).
- `DropdownContentWrapper`: Type the `children` prop ([#80705](https://github.com/WordPress/gutenberg/pull/80705)).

### Internal

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/angle-picker-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function Example() {

### `as`

- Type: `"symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | ...`
- Type: `keyof IntrinsicElements | JSXElementConstructor<any>`
- Required: No

The HTML element or React component to render the component as.
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/base-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ const MyCustomTextareaControl = ({ children, ...baseProps }) => (

### `as`

- Type: `ElementType<any, keyof IntrinsicElements>`
- Type: `"symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | ...`
- Required: Yes

The HTML element or React component to render the component as.
The HTML element to render the component as.

### `className`

Expand Down Expand Up @@ -107,7 +107,7 @@ const MyBaseControl = () => (

##### `as`

- Type: `"symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | ...`
- Type: `keyof IntrinsicElements | JSXElementConstructor<any>`
- Required: No

The HTML element or React component to render the component as.
Expand Down
6 changes: 6 additions & 0 deletions packages/components/src/confirm-dialog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ type DialogInputEvent =

An optional `title` for the dialog. Setting a title will render it in a title bar at the top of the dialog, making it a bit taller. The bar will also include an `x` close button at the top-right corner.

### `size`: `'small' | 'medium' | 'large' | 'fill'`

- Required: No

Size of the underlying [`Modal`](/packages/components/src/modal/README.md). See `Modal`'s `size` prop for details.

### `children`: `React.ReactNode`

- Required: Yes
Expand Down
4 changes: 4 additions & 0 deletions packages/components/src/confirm-dialog/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export type ConfirmDialogProps = {
* The actual message for the dialog. It's passed as children and any valid `ReactNode` is accepted.
*/
children: ReactNode;
/**
* Size of the underlying Modal. See `Modal`'s `size` prop.
*/
size?: ModalProps[ 'size' ];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This prop didn't land in the README for the component.

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.

The short answer is that the component lacks a docs-manifest.json which would opt it into automatic documentation, and so its README is maintained manually. We could update it manually, but I'm also curious to dig into why it doesn't have a manifest 🙂

@aduth aduth Jul 29, 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 tried adding the docs-manifest.json and it works (also brings other missing props like isBusy), but it causes a lot of unrelated changes to the README.md (changes formatting quite a bit) that I'd suggest we tackle separately. In the interim, da70077 adds the manual prop documentation.

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.

Separate pull request for the auto-documentation: #80866

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could update it manually, but I'm also curious to dig into why it doesn't have a manifest 🙂

I set up the readme autogen system pretty late in the game, so a lot of them simply aren't migrated yet. Nothing more 😄

/**
* The callback that's called when the user confirms.
* A confirmation can happen when the `OK` button is clicked or when `Enter` is pressed.
Expand Down
52 changes: 41 additions & 11 deletions packages/components/src/context/wordpress-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
*/
import type * as React from 'react';

/**
* Loose intrinsic attribute bag used when a polymorphic component is rendered
* with an `as` prop. Previous implementations enabled precise typings for the
* given `as` element (e.g. `as="label"` unlocks `htmlFor`), but doing so
* contributed to high memory usage and slow compilation times.
*/
type PolymorphicIntrinsicProps = Omit<
React.AllHTMLAttributes< Element > & React.SVGAttributes< Element >,
'as' | 'children'
>;

// Based on https://github.com/ariakit/ariakit/blob/reakit/packages/reakit-utils/src/types.ts
export type WordPressComponentProps<
/** Prop types. */
Expand All @@ -24,24 +35,43 @@ export type WordPressComponentProps<
( IsPolymorphic extends true
? {
/** The HTML element or React component to render the component as. */
as?: T | keyof React.JSX.IntrinsicElements;
as?:
| T
| keyof React.JSX.IntrinsicElements
| React.JSXElementConstructor< any >;
}
: {} );

export type WordPressComponent<
T extends React.ElementType | null,
O,
IsPolymorphic extends boolean,
> = {
< TT extends React.ElementType >(
props: WordPressComponentProps< O, TT, false > &
( IsPolymorphic extends true
? {
/** The HTML element or React component to render the component as. */
as: TT;
}
: {} )
): React.ReactNode;
> = ( IsPolymorphic extends true
? {
/**
* Intrinsic `as` (e.g. `as="label"`): accept a flat HTML/SVG attribute
* bag instead of remapping to that tag's props.
*/
(
props: WordPressComponentProps< O, T, false > & {
/** The HTML element to render the component as. */
as: keyof React.JSX.IntrinsicElements;
} & Omit< PolymorphicIntrinsicProps, keyof O >
): React.ReactNode;
/**
* Component `as` (e.g. `as={ Item }`): remap to that component's props.
*/
< C extends React.JSXElementConstructor< any > >(
props: WordPressComponentProps< O, T, false > & {
/** The React component to render the component as. */
as: C;
} & Omit<
React.ComponentPropsWithoutRef< C >,
'as' | keyof O | 'children'
>
): React.ReactNode;
}
: unknown ) & {
( props: WordPressComponentProps< O, T, IsPolymorphic > ): React.ReactNode;
displayName?: string;
/**
Expand Down
4 changes: 4 additions & 0 deletions packages/components/src/dropdown/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ type CallbackProps = {
};

export type DropdownContentWrapperProps = {
/**
* The content to render inside the wrapper.
*/
children?: ReactNode;
Comment on lines +13 to +16

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.

From what I understand, this should have always been here, and the previous polymorphism types incorrectly typed children for non-polymorphic components. Generally it should be expected that components define their own children types, which we're more consistent about in @wordpress/ui (e.g. ComponentProps explicitly omits children)

/**
* Amount of padding to apply on the dropdown content.
*
Expand Down
10 changes: 5 additions & 5 deletions packages/components/src/menu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ component, and the `Menu.Popover` component.

### `as`

- Type: `ElementType<any, keyof IntrinsicElements>`
- Required: Yes
- Type: `any`
- Required: No

The HTML element or React component to render the component as.

Expand Down Expand Up @@ -64,7 +64,7 @@ A callback that gets called when the `open` state changes.

### `placement`

- Type: `"top" | "bottom" | "left" | "right" | "top-start" | "bottom-start" | "left-start" | "right-start" | "top-end" | "bottom-end" | ...`
- Type: `"left" | "right" | "top" | "bottom" | "left-start" | "right-start" | "top-start" | "bottom-start" | "left-end" | "right-end" | ...`
- Required: No
- Default: `'bottom-start' for root-level menus, 'right-start' for submenus`

Expand Down Expand Up @@ -466,7 +466,7 @@ Renders a menu item's label text. It should be wrapped with `Menu.Item`,

##### `as`

- Type: `"symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | ...`
- Type: `keyof IntrinsicElements | JSXElementConstructor<any>`
- Required: No

The HTML element or React component to render the component as.
Expand All @@ -480,7 +480,7 @@ Renders a menu item's help text. It should be wrapped with `Menu.Item`,

##### `as`

- Type: `"symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | ...`
- Type: `keyof IntrinsicElements | JSXElementConstructor<any>`
- Required: No

The HTML element or React component to render the component as.
Expand Down
4 changes: 4 additions & 0 deletions packages/components/src/toggle-group-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ export type ToggleGroupControlProps = Pick<
* `ToggleGroupControlOptionIcon` components.
*/
children: ReactNode;
/**
* Whether the control is disabled.
*/
disabled?: boolean;
Comment thread
manzoorwanijk marked this conversation as resolved.
Resolved
/**
* The size variant of the control.
*
Expand Down
1 change: 1 addition & 0 deletions packages/preferences/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Internal

- Remove unused `isAction` prop from preferences modal tab buttons (`Item` has ignored it since it was replaced by `onClick`) ([#80705](https://github.com/WordPress/gutenberg/pull/80705)).
- Update `exports` to use subpath patterns instead of deprecated trailing `/` folder mappings ([#80270](https://github.com/WordPress/gutenberg/pull/80270)).

## 4.51.0 (2026-07-14)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ export default function PreferencesModalTabs( {
<Navigator.Button
key={ tab.name }
path={ `/${ tab.name }` }
// @ts-expect-error: Navigator.Button is currently typed in a way that prevents Item from being passed in
as={ Item }
isAction

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.

This is safe:

- Removed `isAction` prop from `Item`. The component will now rely on `onClick` to render as a `button` ([35152](https://github.com/WordPress/gutenberg/pull/35152)).

Navigator.Button provides onClick:

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.

The reason the removal has to happen is because the TypeScript error on the line above assigning as={ Item } no longer errors, and the suppression through @ts-expect-error was subsequently not checking this prop, which had been removed from the types in #35152. Once the props were checked, it flagged the prop as not part of the Item props types.

>
<HStack justify="space-between">
<FlexItem>
Expand Down
Loading