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: 3 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
- `PaletteEdit`: Add a duotone variant. Passing `duotones` (with an optional `colorPalette` for the shadows and highlights pickers) edits duotone presets with the same UI as colors and gradients. Palette colors that do not resolve to a concrete value, such as `color-mix()`, are left out of the duotone pickers, since a duotone built from one cannot be rendered, and the rest are normalized to hex, since the front end's duotone parser does not accept CSS named colors ([#81605](https://github.com/WordPress/gutenberg/pull/81605)).
- `DuotonePicker`: Add `selectedSlug` prop for slug-based selection and pass the picked preset's index and slug to `onChange`, so two presets sharing a pair of colors keep their identity ([#81605](https://github.com/WordPress/gutenberg/pull/81605)).
- `PaletteEdit`: Name the swatch picker after the palette's heading, so it is announced as Theme, Default or Custom rather than an unlabelled list ([#81605](https://github.com/WordPress/gutenberg/pull/81605)).
- `ConfirmDialog`: Add the `title` prop to the types; the component already forwarded it to the underlying `Modal` ([#81847](https://github.com/WordPress/gutenberg/pull/81847)).
- `TextControl`, `TextareaControl`, `FormTokenField`, `ContentEditableControl`, `ComboboxControl`: Align focus and hover styles with the design system ([#81357](https://github.com/WordPress/gutenberg/pull/81357)).
- `InputControl`, `SelectControl`, `CustomSelectControl`: Align focus rings with the design system ([#80417](https://github.com/WordPress/gutenberg/pull/80417)).

### Bug Fixes

- `ConfirmDialog`: Preserve `title` as the dialog's accessible name when the header is hidden ([#81847](https://github.com/WordPress/gutenberg/pull/81847)).
- `DuotonePicker`: Do not render the custom controls wrapper when `disableCustomDuotone` is set, so a read-only picker no longer adds trailing padding below its swatches ([#81605](https://github.com/WordPress/gutenberg/pull/81605)).
- `Modal`: Prevent an Escape key press that dismisses the modal from propagating to underlying overlays. ([#81785](https://github.com/WordPress/gutenberg/pull/81785))
- `BoxControl`: Update the opposite side when ALT is held on the left or right input, which each updated themselves instead ([#81530](https://github.com/WordPress/gutenberg/pull/81530)).
Expand Down
16 changes: 16 additions & 0 deletions packages/components/src/confirm-dialog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ function Example() {

## Props

### `__experimentalHideHeader`

- Type: `boolean`
- Required: No
- Default: `true`

Whether the underlying `Modal` should hide its header, `title` included.

### `children`

- Type: `ReactNode`
Expand Down Expand Up @@ -150,3 +158,11 @@ dialog to close when the user cancels.
- Required: No

Size of the underlying Modal. See `Modal`'s `size` prop.

### `title`

- Type: `string`
- Required: No

The title of the underlying `Modal`: its accessible name, and the
visible heading unless `__experimentalHideHeader` is `true`.
8 changes: 7 additions & 1 deletion packages/components/src/confirm-dialog/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const UnconnectedConfirmDialog = (
confirmButtonText,
cancelButtonText,
isBusy,
title,
__experimentalHideHeader = true,
...otherProps
} = useContextSystem( props, 'ConfirmDialog' );

Expand Down Expand Up @@ -81,7 +83,11 @@ const UnconnectedConfirmDialog = (
isDismissible
ref={ forwardedRef }
overlayClassName={ wrapperClassName }
__experimentalHideHeader
title={ title }
contentLabel={
__experimentalHideHeader ? title : undefined
}
__experimentalHideHeader={ __experimentalHideHeader }
{ ...otherProps }
>
<VStack spacing={ 8 }>
Expand Down
41 changes: 41 additions & 0 deletions packages/components/src/confirm-dialog/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,47 @@ describe( 'Confirm', () => {
expect( el ).toBeInTheDocument();
} );
} );
it( 'uses title as the dialog accessible name while the default header is hidden', () => {
const title = 'Delete item?';

render(
<ConfirmDialog
title={ title }
onConfirm={ noop }
onCancel={ noop }
>
Are you sure?
</ConfirmDialog>
);

expect(
screen.getByRole( 'dialog', { name: title } )
).toBeInTheDocument();
expect(
screen.queryByRole( 'heading', { name: title } )
).not.toBeInTheDocument();
} );
it( 'renders the title heading when __experimentalHideHeader is false', () => {
const title = 'Delete item?';

render(
<ConfirmDialog
title={ title }
__experimentalHideHeader={ false }
onConfirm={ noop }
onCancel={ noop }
>
Are you sure?
</ConfirmDialog>
);

expect(
screen.getByRole( 'dialog', { name: title } )
).toBeInTheDocument();
expect(
screen.getByRole( 'heading', { name: title } )
).toBeInTheDocument();
} );
it( 'should render correctly with custom button labels', () => {
const cancelButtonText = 'No thanks';
const confirmButtonText = 'Yes please!';
Expand Down
11 changes: 11 additions & 0 deletions packages/components/src/confirm-dialog/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,15 @@ export type ConfirmDialogProps = {
* Both buttons will be disabled.
*/
isBusy?: boolean;
/**
* The title of the underlying `Modal`: its accessible name, and the
* visible heading unless `__experimentalHideHeader` is `true`.
*/
title?: ModalProps[ 'title' ];
/**
* Whether the underlying `Modal` should hide its header, `title` included.
*
* @default true
*/
__experimentalHideHeader?: ModalProps[ '__experimentalHideHeader' ];
Comment thread
manzoorwanijk marked this conversation as resolved.
Resolved
};
4 changes: 3 additions & 1 deletion routes/connectors-home/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
},
"devDependencies": {
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.2",
"@testing-library/user-event": "^14.6.1"
"@testing-library/user-event": "^14.6.1",
"@types/jest": "^30.0.0"
},
"peerDependencies": {
"react": "^18 || ^19"
Expand Down
4 changes: 3 additions & 1 deletion routes/connectors-home/stage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ function ConnectorsPage() {
( connector: ConnectorConfig ) =>
connector.plugin?.file?.split( '/' )[ 0 ]
)
.filter( ( slug ): slug is string => !! slug )
.filter(
( slug: string | undefined ): slug is string => !! slug
)
)
).sort();
const installedPluginSlugs = new Set(
Expand Down
32 changes: 18 additions & 14 deletions routes/connectors-home/test/ai-plugin-callout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@testing-library/jest-dom';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { useDispatch, useSelect } from '@wordpress/data';
Expand Down Expand Up @@ -25,7 +26,7 @@ jest.mock( '@wordpress/components', () => {
onClick?: () => void;
disabled?: boolean;
},
ref
ref: unknown
) =>
href
? createElement( 'a', { ref, href }, children )
Expand Down Expand Up @@ -55,20 +56,23 @@ jest.mock( '@wordpress/data', () => ( {
createSelector: jest.fn( ( fn ) => fn ),
createRegistrySelector: jest.fn( ( fn ) => fn ),
createReduxStore: jest.fn( () => ( {} ) ),
combineReducers: jest.fn( ( reducers ) => ( state = {}, action ) => {
const newState: Record< string, unknown > = {};

Object.keys( reducers ).forEach( ( key ) => {
newState[ key ] = reducers[ key ](
( state as Record< string, unknown > )[ key ],
action
);
} );

return newState;
} ),
combineReducers: jest.fn(
( reducers ) =>
( state = {}, action: unknown ) => {
const newState: Record< string, unknown > = {};

Object.keys( reducers ).forEach( ( key ) => {
newState[ key ] = reducers[ key ](
( state as Record< string, unknown > )[ key ],
action
);
} );

return newState;
}
),
register: jest.fn(),
keyedReducer: jest.fn( () => ( reducer ) => reducer ),
keyedReducer: jest.fn( () => ( reducer: unknown ) => reducer ),
} ) );

jest.mock( '../default-connectors', () => ( {
Expand Down
29 changes: 29 additions & 0 deletions routes/connectors-home/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://json.schemastore.org/tsconfig.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"jsx": "react-jsx",
"rootDir": ".",
"noEmit": true,
"emitDeclarationOnly": false,
"composite": false,
"types": [ "style-imports" ]
},
"references": [
{ "path": "../../packages/a11y/tsconfig.build.json" },
{ "path": "../../packages/admin-ui/tsconfig.build.json" },
{ "path": "../../packages/api-fetch/tsconfig.build.json" },
{ "path": "../../packages/components/tsconfig.build.json" },
{ "path": "../../packages/connectors/tsconfig.build.json" },
{ "path": "../../packages/core-data/tsconfig.build.json" },
{ "path": "../../packages/data" },
{ "path": "../../packages/element/tsconfig.build.json" },
{ "path": "../../packages/i18n/tsconfig.build.json" },
{ "path": "../../packages/icons/tsconfig.build.json" },
{ "path": "../../packages/notices/tsconfig.build.json" },
{ "path": "../../packages/ui/tsconfig.build.json" },
{ "path": "../../packages/url" }
],
"include": [ "**/*.ts", "**/*.tsx" ],
"exclude": [ "**/test/**", "build", "node_modules" ]
}
25 changes: 25 additions & 0 deletions routes/connectors-home/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "https://json.schemastore.org/tsconfig.json",
"extends": "../../tsconfig.dev.base.json",
/* Route tests live beside the route sources, not under src. */

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.

TIL that TS config JSON files don't mind code comments! Just double-checking, though, tsc doesn't mind that this code comment is here, but do we have anything else that minds that this isn't (purely) valid JSON.

I assume it's fine since all the Github actions are passing, and the build succeeds locally.

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.

Yes, tsconfig have always supported comments.

"compilerOptions": {
"jsx": "react-jsx",
"rootDir": ".",
"composite": false,
"types": [ "jest" ]
},
"include": [ "**/test/**/*.ts", "**/test/**/*.tsx" ],
"exclude": [ "build", "node_modules" ],
"references": [
{ "path": "../../packages/components/tsconfig.build.json" },
{ "path": "../../packages/connectors/tsconfig.build.json" },
{ "path": "../../packages/core-data/tsconfig.build.json" },
{ "path": "../../packages/data" },
{ "path": "../../packages/element/tsconfig.build.json" },
{ "path": "../../packages/i18n/tsconfig.build.json" },
{ "path": "../../packages/notices/tsconfig.build.json" },
{ "path": "../../packages/private-apis" },
{ "path": "../../packages/ui/tsconfig.build.json" },
{ "path": "../../packages/url" }
]
}
26 changes: 26 additions & 0 deletions routes/experiments-home/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "https://json.schemastore.org/tsconfig.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"jsx": "react-jsx",
"rootDir": ".",
"noEmit": true,
"emitDeclarationOnly": false,
"composite": false,
"types": [ "style-imports" ]
},
"references": [
{ "path": "../../packages/admin-ui/tsconfig.build.json" },
{ "path": "../../packages/api-fetch/tsconfig.build.json" },
{ "path": "../../packages/components/tsconfig.build.json" },
{ "path": "../../packages/core-data/tsconfig.build.json" },
{ "path": "../../packages/data" },
{ "path": "../../packages/dataviews/tsconfig.build.json" },
{ "path": "../../packages/element/tsconfig.build.json" },
{ "path": "../../packages/i18n/tsconfig.build.json" },
{ "path": "../../packages/notices/tsconfig.build.json" },
{ "path": "../../packages/ui/tsconfig.build.json" }
],
"include": [ "**/*.ts", "**/*.tsx" ],
"exclude": [ "build", "node_modules" ]
}
28 changes: 28 additions & 0 deletions routes/font-list/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://json.schemastore.org/tsconfig.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"jsx": "react-jsx",
"rootDir": ".",
"noEmit": true,
"emitDeclarationOnly": false,
"composite": false,
"types": [ "style-imports" ]
},
"references": [
{ "path": "../../packages/admin-ui/tsconfig.build.json" },
{ "path": "../../packages/components/tsconfig.build.json" },
{ "path": "../../packages/compose/tsconfig.build.json" },
{ "path": "../../packages/core-data/tsconfig.build.json" },
{ "path": "../../packages/data" },
{ "path": "../../packages/editor/tsconfig.build.json" },
{ "path": "../../packages/element/tsconfig.build.json" },
{ "path": "../../packages/global-styles-engine/tsconfig.build.json" },
{ "path": "../../packages/global-styles-ui" },
{ "path": "../../packages/i18n/tsconfig.build.json" },
{ "path": "../../packages/private-apis" },
{ "path": "../../packages/route" }
],
"include": [ "**/*.ts", "**/*.tsx" ],
"exclude": [ "build", "node_modules" ]
}
15 changes: 15 additions & 0 deletions routes/fonts-home/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://json.schemastore.org/tsconfig.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"jsx": "react-jsx",
"rootDir": ".",
"noEmit": true,
"emitDeclarationOnly": false,
"composite": false,
"types": []
},
"references": [ { "path": "../../packages/route" } ],
"include": [ "**/*.ts", "**/*.tsx" ],
"exclude": [ "build", "node_modules" ]
}
5 changes: 4 additions & 1 deletion routes/guidelines/bootstrap-block-registry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { dispatch } from '@wordpress/data';
import { store as blocksStore } from '@wordpress/blocks';
import { registerCoreBlocks } from '@wordpress/block-library';
import {
registerCoreBlocks,
// @ts-expect-error - No type declarations available for @wordpress/block-library
} from '@wordpress/block-library';

let bootstrapped = false;

Expand Down
2 changes: 1 addition & 1 deletion routes/guidelines/components/action-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
__experimentalHStack as HStack,
} from '@wordpress/components';

interface ActionProps {
export interface ActionProps {
slug: 'import' | 'export' | 'revert';
title: string;
description: string;
Expand Down
10 changes: 8 additions & 2 deletions routes/guidelines/components/block-guidelines.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import {
__experimentalVStack as VStack,
__experimentalHStack as HStack,
__experimentalConfirmDialog as ConfirmDialog,
type IconType,
} from '@wordpress/components';
import {
DataViews,
filterSortAndPaginate,
type Field,
type View,
} from '@wordpress/dataviews';
import { __, sprintf } from '@wordpress/i18n';
Expand Down Expand Up @@ -40,9 +42,11 @@ const initialView: View = {
interface DataRow {
id: string;
label: string;
guidelines: string;
icon?: IconType;
}

const fields = [
const fields: Field< DataRow >[] = [
{
id: 'icon',
label: __( 'Icon' ),
Expand Down Expand Up @@ -97,7 +101,9 @@ export default function BlockGuidelines( {
label: block.title,
guidelines:
bySlug[ blockSlug( block.name ) ]?.content ?? '',
icon: block.icon?.src,
/* Block registry icons are renderable by `Icon`, but the
registry types do not model them. */
icon: block.icon?.src as IconType | undefined,
} ) ),
[ contentBlocks, bySlug ]
);
Expand Down
Loading
Loading