@wordpress/customize-widgets 5.56.0 → 5.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 5.57.0 (2026-10-07)
6
+
7
+ ### Bug Fixes
8
+
9
+ - Error boundary: Explicitly announce the error title and description, excluding action labels ([#82737](https://github.com/WordPress/gutenberg/pull/82737)).
10
+
5
11
  ## 5.56.0 (2026-09-23)
6
12
 
7
13
  ### Bug Fixes
@@ -23,11 +23,20 @@ __export(error_boundary_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(error_boundary_exports);
25
25
  var import_element = require("@wordpress/element");
26
+ var import_a11y = require("@wordpress/a11y");
26
27
  var import_i18n = require("@wordpress/i18n");
27
28
  var import_ui = require("@wordpress/ui");
28
29
  var import_compose = require("@wordpress/compose");
29
30
  var import_hooks = require("@wordpress/hooks");
30
31
  var import_jsx_runtime = require("react/jsx-runtime");
32
+ function getErrorNotice() {
33
+ return {
34
+ title: (0, import_i18n.__)("The editor has crashed"),
35
+ description: (0, import_i18n.__)(
36
+ "An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search."
37
+ )
38
+ };
39
+ }
31
40
  function getErrorName(error) {
32
41
  return error instanceof Error && error.name || "Error";
33
42
  }
@@ -116,6 +125,8 @@ var ErrorBoundary = class extends import_element.Component {
116
125
  };
117
126
  }
118
127
  componentDidCatch(error, errorInfo) {
128
+ const { title, description } = getErrorNotice();
129
+ (0, import_a11y.speak)(`${title}. ${description}`, "assertive");
119
130
  this.setState({ componentStack: errorInfo?.componentStack });
120
131
  (0, import_hooks.doAction)("editor.ErrorBoundary.errorLogged", error, errorInfo);
121
132
  }
@@ -127,6 +138,7 @@ var ErrorBoundary = class extends import_element.Component {
127
138
  if (!error) {
128
139
  return this.props.children;
129
140
  }
141
+ const { title, description } = getErrorNotice();
130
142
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
131
143
  import_ui.Stack,
132
144
  {
@@ -135,10 +147,8 @@ var ErrorBoundary = class extends import_element.Component {
135
147
  gap: "lg",
136
148
  children: [
137
149
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Notice.Root, { intent: "error", children: [
138
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Notice.Title, { children: (0, import_i18n.__)("The editor has crashed") }),
139
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Notice.Description, { children: (0, import_i18n.__)(
140
- "An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search."
141
- ) }),
150
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Notice.Title, { children: title }),
151
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Notice.Description, { children: description }),
142
152
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Notice.Actions, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
143
153
  CopyButton,
144
154
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/error-boundary/index.jsx"],
4
- "sourcesContent": ["import { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n// eslint-disable-next-line @wordpress/use-recommended-components -- The fallback UI renders outside the editor's notice system.\nimport { Card, CollapsibleCard, Notice, Stack, Text } from '@wordpress/ui';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { doAction } from '@wordpress/hooks';\n\n// A boundary catches whatever was thrown, which is not always an `Error`.\nfunction getErrorName( error ) {\n\treturn ( error instanceof Error && error.name ) || 'Error';\n}\n\nfunction getErrorMessage( error ) {\n\tif ( typeof error === 'string' && error ) {\n\t\treturn error;\n\t}\n\n\tif ( typeof error?.message === 'string' && error.message ) {\n\t\treturn error.message;\n\t}\n\n\treturn 'An unknown error occurred.';\n}\n\n// The sections of the report, shared by the copied Markdown and the details\n// panel so that the two cannot drift apart. Deliberately untranslated: both\n// are developer-facing, and the report is pasted into a bug report.\nfunction getErrorSections( error, componentStack ) {\n\tconst sections = [\n\t\t{ label: getErrorName( error ), content: getErrorMessage( error ) },\n\t];\n\n\tif ( error?.stack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Stack',\n\t\t\tcontent: error.stack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tif ( componentStack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Component stack',\n\t\t\tcontent: componentStack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tsections.push( {\n\t\tlabel: 'Environment',\n\t\tcontent: `User agent: ${ window.navigator.userAgent }`,\n\t\tpreformatted: true,\n\t} );\n\n\treturn sections;\n}\n\n// Markdown, so the report stays readable as plain text and renders when pasted\n// into a bug report.\nfunction getErrorReport( error, componentStack ) {\n\tconst sections = getErrorSections( error, componentStack ).map(\n\t\t( { label, content, preformatted } ) =>\n\t\t\t`**${ label }**\\n\\n${\n\t\t\t\tpreformatted ? `\\`\\`\\`\\n${ content }\\n\\`\\`\\`` : content\n\t\t\t}`\n\t);\n\n\treturn [ '### Error report', ...sections ].join( '\\n\\n' );\n}\n\nfunction CopyButton( { text, children, variant = 'outline' } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Notice.ActionButton variant={ variant } ref={ ref }>\n\t\t\t{ children }\n\t\t</Notice.ActionButton>\n\t);\n}\n\nfunction ErrorReport( { error, componentStack } ) {\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"customize-widgets-error-boundary__report\"\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"md\"\n\t\t>\n\t\t\t{ getErrorSections( error, componentStack ).map(\n\t\t\t\t( { label, content } ) => (\n\t\t\t\t\t<Stack key={ label } direction=\"column\" gap=\"xs\">\n\t\t\t\t\t\t<Text variant=\"heading-md\">{ label }</Text>\n\t\t\t\t\t\t<pre className=\"customize-widgets-error-boundary__report-section\">\n\t\t\t\t\t\t\t{ content }\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t</Stack>\n\t\t\t\t)\n\t\t\t) }\n\t\t</Stack>\n\t);\n}\n\nfunction ErrorDetails( { error, componentStack } ) {\n\treturn (\n\t\t<CollapsibleCard.Root className=\"customize-widgets-error-boundary__details\">\n\t\t\t<CollapsibleCard.Header>\n\t\t\t\t<Card.Title>{ __( 'Error details' ) }</Card.Title>\n\t\t\t</CollapsibleCard.Header>\n\t\t\t<CollapsibleCard.Content>\n\t\t\t\t<ErrorReport\n\t\t\t\t\terror={ error }\n\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t/>\n\t\t\t</CollapsibleCard.Content>\n\t\t</CollapsibleCard.Root>\n\t);\n}\n\nexport default class ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t\tcomponentStack: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error, errorInfo ) {\n\t\tthis.setState( { componentStack: errorInfo?.componentStack } );\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error, errorInfo );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tconst { error, componentStack } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn (\n\t\t\t<Stack\n\t\t\t\tclassName=\"customize-widgets-error-boundary\"\n\t\t\t\tdirection=\"column\"\n\t\t\t\tgap=\"lg\"\n\t\t\t>\n\t\t\t\t<Notice.Root intent=\"error\">\n\t\t\t\t\t<Notice.Title>\n\t\t\t\t\t\t{ __( 'The editor has crashed' ) }\n\t\t\t\t\t</Notice.Title>\n\t\t\t\t\t<Notice.Description>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Notice.Description>\n\t\t\t\t\t<Notice.Actions>\n\t\t\t\t\t\t<CopyButton\n\t\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\t\ttext={ () =>\n\t\t\t\t\t\t\t\tgetErrorReport( error, componentStack )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Copy error' ) }\n\t\t\t\t\t\t</CopyButton>\n\t\t\t\t\t</Notice.Actions>\n\t\t\t\t</Notice.Root>\n\t\t\t\t{ globalThis.SCRIPT_DEBUG ? (\n\t\t\t\t\t<ErrorDetails\n\t\t\t\t\t\terror={ error }\n\t\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t\t/>\n\t\t\t\t) : null }\n\t\t\t</Stack>\n\t\t);\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA0B;AAC1B,kBAAmB;AAEnB,gBAA2D;AAC3D,qBAAmC;AACnC,mBAAyB;AAoEvB;AAjEF,SAAS,aAAc,OAAQ;AAC9B,SAAS,iBAAiB,SAAS,MAAM,QAAU;AACpD;AAEA,SAAS,gBAAiB,OAAQ;AACjC,MAAK,OAAO,UAAU,YAAY,OAAQ;AACzC,WAAO;AAAA,EACR;AAEA,MAAK,OAAO,OAAO,YAAY,YAAY,MAAM,SAAU;AAC1D,WAAO,MAAM;AAAA,EACd;AAEA,SAAO;AACR;AAKA,SAAS,iBAAkB,OAAO,gBAAiB;AAClD,QAAM,WAAW;AAAA,IAChB,EAAE,OAAO,aAAc,KAAM,GAAG,SAAS,gBAAiB,KAAM,EAAE;AAAA,EACnE;AAEA,MAAK,OAAO,OAAQ;AACnB,aAAS,KAAM;AAAA,MACd,OAAO;AAAA,MACP,SAAS,MAAM,MAAM,KAAK;AAAA,MAC1B,cAAc;AAAA,IACf,CAAE;AAAA,EACH;AAEA,MAAK,gBAAiB;AACrB,aAAS,KAAM;AAAA,MACd,OAAO;AAAA,MACP,SAAS,eAAe,KAAK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A;AAAA,QACA;AAAA;AAAA,IACD,GACD;AAAA,KACD;AAEF;AAEA,IAAqB,gBAArB,cAA2C,yBAAU;AAAA,EACpD,cAAc;AACb,UAAO,GAAG,SAAU;AAEpB,SAAK,QAAQ;AAAA,MACZ,OAAO;AAAA,MACP,gBAAgB;AAAA,IACjB;AAAA,EACD;AAAA,EAEA,kBAAmB,OAAO,WAAY;AACrC,SAAK,SAAU,EAAE,gBAAgB,WAAW,eAAe,CAAE;AAC7D,+BAAU,oCAAoC,OAAO,SAAU;AAAA,EAChE;AAAA,EAEA,OAAO,yBAA0B,OAAQ;AACxC,WAAO,EAAE,MAAM;AAAA,EAChB;AAAA,EAEA,SAAS;AACR,UAAM,EAAE,OAAO,eAAe,IAAI,KAAK;AACvC,QAAK,CAAE,OAAQ;AACd,aAAO,KAAK,MAAM;AAAA,IACnB;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,WAAU;AAAA,QACV,KAAI;AAAA,QAEJ;AAAA,uDAAC,iBAAO,MAAP,EAAY,QAAO,SACnB;AAAA,wDAAC,iBAAO,OAAP,EACE,8BAAI,wBAAyB,GAChC;AAAA,YACA,4CAAC,iBAAO,aAAP,EACE;AAAA,cACD;AAAA,YACD,GACD;AAAA,YACA,4CAAC,iBAAO,SAAP,EACA;AAAA,cAAC;AAAA;AAAA,gBACA,SAAQ;AAAA,gBACR,MAAO,MACN,eAAgB,OAAO,cAAe;AAAA,gBAGrC,8BAAI,YAAa;AAAA;AAAA,YACpB,GACD;AAAA,aACD;AAAA,UACE,WAAW,eACZ;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA;AAAA,UACD,IACG;AAAA;AAAA;AAAA,IACL;AAAA,EAEF;AACD;",
4
+ "sourcesContent": ["import { Component } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\nimport { __ } from '@wordpress/i18n';\nimport { Card, CollapsibleCard, Notice, Stack, Text } from '@wordpress/ui';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { doAction } from '@wordpress/hooks';\n\nfunction getErrorNotice() {\n\treturn {\n\t\ttitle: __( 'The editor has crashed' ),\n\t\tdescription: __(\n\t\t\t'An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.'\n\t\t),\n\t};\n}\n\n// A boundary catches whatever was thrown, which is not always an `Error`.\nfunction getErrorName( error ) {\n\treturn ( error instanceof Error && error.name ) || 'Error';\n}\n\nfunction getErrorMessage( error ) {\n\tif ( typeof error === 'string' && error ) {\n\t\treturn error;\n\t}\n\n\tif ( typeof error?.message === 'string' && error.message ) {\n\t\treturn error.message;\n\t}\n\n\treturn 'An unknown error occurred.';\n}\n\n// The sections of the report, shared by the copied Markdown and the details\n// panel so that the two cannot drift apart. Deliberately untranslated: both\n// are developer-facing, and the report is pasted into a bug report.\nfunction getErrorSections( error, componentStack ) {\n\tconst sections = [\n\t\t{ label: getErrorName( error ), content: getErrorMessage( error ) },\n\t];\n\n\tif ( error?.stack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Stack',\n\t\t\tcontent: error.stack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tif ( componentStack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Component stack',\n\t\t\tcontent: componentStack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tsections.push( {\n\t\tlabel: 'Environment',\n\t\tcontent: `User agent: ${ window.navigator.userAgent }`,\n\t\tpreformatted: true,\n\t} );\n\n\treturn sections;\n}\n\n// Markdown, so the report stays readable as plain text and renders when pasted\n// into a bug report.\nfunction getErrorReport( error, componentStack ) {\n\tconst sections = getErrorSections( error, componentStack ).map(\n\t\t( { label, content, preformatted } ) =>\n\t\t\t`**${ label }**\\n\\n${\n\t\t\t\tpreformatted ? `\\`\\`\\`\\n${ content }\\n\\`\\`\\`` : content\n\t\t\t}`\n\t);\n\n\treturn [ '### Error report', ...sections ].join( '\\n\\n' );\n}\n\nfunction CopyButton( { text, children, variant = 'outline' } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Notice.ActionButton variant={ variant } ref={ ref }>\n\t\t\t{ children }\n\t\t</Notice.ActionButton>\n\t);\n}\n\nfunction ErrorReport( { error, componentStack } ) {\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"customize-widgets-error-boundary__report\"\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"md\"\n\t\t>\n\t\t\t{ getErrorSections( error, componentStack ).map(\n\t\t\t\t( { label, content } ) => (\n\t\t\t\t\t<Stack key={ label } direction=\"column\" gap=\"xs\">\n\t\t\t\t\t\t<Text variant=\"heading-md\">{ label }</Text>\n\t\t\t\t\t\t<pre className=\"customize-widgets-error-boundary__report-section\">\n\t\t\t\t\t\t\t{ content }\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t</Stack>\n\t\t\t\t)\n\t\t\t) }\n\t\t</Stack>\n\t);\n}\n\nfunction ErrorDetails( { error, componentStack } ) {\n\treturn (\n\t\t<CollapsibleCard.Root className=\"customize-widgets-error-boundary__details\">\n\t\t\t<CollapsibleCard.Header>\n\t\t\t\t<Card.Title>{ __( 'Error details' ) }</Card.Title>\n\t\t\t</CollapsibleCard.Header>\n\t\t\t<CollapsibleCard.Content>\n\t\t\t\t<ErrorReport\n\t\t\t\t\terror={ error }\n\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t/>\n\t\t\t</CollapsibleCard.Content>\n\t\t</CollapsibleCard.Root>\n\t);\n}\n\nexport default class ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t\tcomponentStack: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error, errorInfo ) {\n\t\tconst { title, description } = getErrorNotice();\n\t\tspeak( `${ title }. ${ description }`, 'assertive' );\n\t\tthis.setState( { componentStack: errorInfo?.componentStack } );\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error, errorInfo );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tconst { error, componentStack } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\tconst { title, description } = getErrorNotice();\n\n\t\treturn (\n\t\t\t<Stack\n\t\t\t\tclassName=\"customize-widgets-error-boundary\"\n\t\t\t\tdirection=\"column\"\n\t\t\t\tgap=\"lg\"\n\t\t\t>\n\t\t\t\t<Notice.Root intent=\"error\">\n\t\t\t\t\t<Notice.Title>{ title }</Notice.Title>\n\t\t\t\t\t<Notice.Description>{ description }</Notice.Description>\n\t\t\t\t\t<Notice.Actions>\n\t\t\t\t\t\t<CopyButton\n\t\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\t\ttext={ () =>\n\t\t\t\t\t\t\t\tgetErrorReport( error, componentStack )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Copy error' ) }\n\t\t\t\t\t\t</CopyButton>\n\t\t\t\t\t</Notice.Actions>\n\t\t\t\t</Notice.Root>\n\t\t\t\t{ globalThis.SCRIPT_DEBUG ? (\n\t\t\t\t\t<ErrorDetails\n\t\t\t\t\t\terror={ error }\n\t\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t\t/>\n\t\t\t\t) : null }\n\t\t\t</Stack>\n\t\t);\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA0B;AAC1B,kBAAsB;AACtB,kBAAmB;AACnB,gBAA2D;AAC3D,qBAAmC;AACnC,mBAAyB;AA6EvB;AA3EF,SAAS,iBAAiB;AACzB,SAAO;AAAA,IACN,WAAO,gBAAI,wBAAyB;AAAA,IACpC,iBAAa;AAAA,MACZ;AAAA,IACD;AAAA,EACD;AACD;AAGA,SAAS,aAAc,OAAQ;AAC9B,SAAS,iBAAiB,SAAS,MAAM,QAAU;AACpD;AAEA,SAAS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,WAAU;AAAA,QACV,WAAU;AAAA,QACV,KAAI;AAAA,QAEJ;AAAA,uDAAC,iBAAO,MAAP,EAAY,QAAO,SACnB;AAAA,wDAAC,iBAAO,OAAP,EAAe,iBAAO;AAAA,YACvB,4CAAC,iBAAO,aAAP,EAAqB,uBAAa;AAAA,YACnC,4CAAC,iBAAO,SAAP,EACA;AAAA,cAAC;AAAA;AAAA,gBACA,SAAQ;AAAA,gBACR,MAAO,MACN,eAAgB,OAAO,cAAe;AAAA,gBAGrC,8BAAI,YAAa;AAAA;AAAA,YACpB,GACD;AAAA,aACD;AAAA,UACE,WAAW,eACZ;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA;AAAA,UACD,IACG;AAAA;AAAA;AAAA,IACL;AAAA,EAEF;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,10 +1,19 @@
1
1
  // packages/customize-widgets/src/components/error-boundary/index.jsx
2
2
  import { Component } from "@wordpress/element";
3
+ import { speak } from "@wordpress/a11y";
3
4
  import { __ } from "@wordpress/i18n";
4
5
  import { Card, CollapsibleCard, Notice, Stack, Text } from "@wordpress/ui";
5
6
  import { useCopyToClipboard } from "@wordpress/compose";
6
7
  import { doAction } from "@wordpress/hooks";
7
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
+ function getErrorNotice() {
10
+ return {
11
+ title: __("The editor has crashed"),
12
+ description: __(
13
+ "An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search."
14
+ )
15
+ };
16
+ }
8
17
  function getErrorName(error) {
9
18
  return error instanceof Error && error.name || "Error";
10
19
  }
@@ -93,6 +102,8 @@ var ErrorBoundary = class extends Component {
93
102
  };
94
103
  }
95
104
  componentDidCatch(error, errorInfo) {
105
+ const { title, description } = getErrorNotice();
106
+ speak(`${title}. ${description}`, "assertive");
96
107
  this.setState({ componentStack: errorInfo?.componentStack });
97
108
  doAction("editor.ErrorBoundary.errorLogged", error, errorInfo);
98
109
  }
@@ -104,6 +115,7 @@ var ErrorBoundary = class extends Component {
104
115
  if (!error) {
105
116
  return this.props.children;
106
117
  }
118
+ const { title, description } = getErrorNotice();
107
119
  return /* @__PURE__ */ jsxs(
108
120
  Stack,
109
121
  {
@@ -112,10 +124,8 @@ var ErrorBoundary = class extends Component {
112
124
  gap: "lg",
113
125
  children: [
114
126
  /* @__PURE__ */ jsxs(Notice.Root, { intent: "error", children: [
115
- /* @__PURE__ */ jsx(Notice.Title, { children: __("The editor has crashed") }),
116
- /* @__PURE__ */ jsx(Notice.Description, { children: __(
117
- "An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search."
118
- ) }),
127
+ /* @__PURE__ */ jsx(Notice.Title, { children: title }),
128
+ /* @__PURE__ */ jsx(Notice.Description, { children: description }),
119
129
  /* @__PURE__ */ jsx(Notice.Actions, { children: /* @__PURE__ */ jsx(
120
130
  CopyButton,
121
131
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/error-boundary/index.jsx"],
4
- "sourcesContent": ["import { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n// eslint-disable-next-line @wordpress/use-recommended-components -- The fallback UI renders outside the editor's notice system.\nimport { Card, CollapsibleCard, Notice, Stack, Text } from '@wordpress/ui';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { doAction } from '@wordpress/hooks';\n\n// A boundary catches whatever was thrown, which is not always an `Error`.\nfunction getErrorName( error ) {\n\treturn ( error instanceof Error && error.name ) || 'Error';\n}\n\nfunction getErrorMessage( error ) {\n\tif ( typeof error === 'string' && error ) {\n\t\treturn error;\n\t}\n\n\tif ( typeof error?.message === 'string' && error.message ) {\n\t\treturn error.message;\n\t}\n\n\treturn 'An unknown error occurred.';\n}\n\n// The sections of the report, shared by the copied Markdown and the details\n// panel so that the two cannot drift apart. Deliberately untranslated: both\n// are developer-facing, and the report is pasted into a bug report.\nfunction getErrorSections( error, componentStack ) {\n\tconst sections = [\n\t\t{ label: getErrorName( error ), content: getErrorMessage( error ) },\n\t];\n\n\tif ( error?.stack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Stack',\n\t\t\tcontent: error.stack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tif ( componentStack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Component stack',\n\t\t\tcontent: componentStack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tsections.push( {\n\t\tlabel: 'Environment',\n\t\tcontent: `User agent: ${ window.navigator.userAgent }`,\n\t\tpreformatted: true,\n\t} );\n\n\treturn sections;\n}\n\n// Markdown, so the report stays readable as plain text and renders when pasted\n// into a bug report.\nfunction getErrorReport( error, componentStack ) {\n\tconst sections = getErrorSections( error, componentStack ).map(\n\t\t( { label, content, preformatted } ) =>\n\t\t\t`**${ label }**\\n\\n${\n\t\t\t\tpreformatted ? `\\`\\`\\`\\n${ content }\\n\\`\\`\\`` : content\n\t\t\t}`\n\t);\n\n\treturn [ '### Error report', ...sections ].join( '\\n\\n' );\n}\n\nfunction CopyButton( { text, children, variant = 'outline' } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Notice.ActionButton variant={ variant } ref={ ref }>\n\t\t\t{ children }\n\t\t</Notice.ActionButton>\n\t);\n}\n\nfunction ErrorReport( { error, componentStack } ) {\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"customize-widgets-error-boundary__report\"\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"md\"\n\t\t>\n\t\t\t{ getErrorSections( error, componentStack ).map(\n\t\t\t\t( { label, content } ) => (\n\t\t\t\t\t<Stack key={ label } direction=\"column\" gap=\"xs\">\n\t\t\t\t\t\t<Text variant=\"heading-md\">{ label }</Text>\n\t\t\t\t\t\t<pre className=\"customize-widgets-error-boundary__report-section\">\n\t\t\t\t\t\t\t{ content }\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t</Stack>\n\t\t\t\t)\n\t\t\t) }\n\t\t</Stack>\n\t);\n}\n\nfunction ErrorDetails( { error, componentStack } ) {\n\treturn (\n\t\t<CollapsibleCard.Root className=\"customize-widgets-error-boundary__details\">\n\t\t\t<CollapsibleCard.Header>\n\t\t\t\t<Card.Title>{ __( 'Error details' ) }</Card.Title>\n\t\t\t</CollapsibleCard.Header>\n\t\t\t<CollapsibleCard.Content>\n\t\t\t\t<ErrorReport\n\t\t\t\t\terror={ error }\n\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t/>\n\t\t\t</CollapsibleCard.Content>\n\t\t</CollapsibleCard.Root>\n\t);\n}\n\nexport default class ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t\tcomponentStack: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error, errorInfo ) {\n\t\tthis.setState( { componentStack: errorInfo?.componentStack } );\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error, errorInfo );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tconst { error, componentStack } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn (\n\t\t\t<Stack\n\t\t\t\tclassName=\"customize-widgets-error-boundary\"\n\t\t\t\tdirection=\"column\"\n\t\t\t\tgap=\"lg\"\n\t\t\t>\n\t\t\t\t<Notice.Root intent=\"error\">\n\t\t\t\t\t<Notice.Title>\n\t\t\t\t\t\t{ __( 'The editor has crashed' ) }\n\t\t\t\t\t</Notice.Title>\n\t\t\t\t\t<Notice.Description>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Notice.Description>\n\t\t\t\t\t<Notice.Actions>\n\t\t\t\t\t\t<CopyButton\n\t\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\t\ttext={ () =>\n\t\t\t\t\t\t\t\tgetErrorReport( error, componentStack )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Copy error' ) }\n\t\t\t\t\t\t</CopyButton>\n\t\t\t\t\t</Notice.Actions>\n\t\t\t\t</Notice.Root>\n\t\t\t\t{ globalThis.SCRIPT_DEBUG ? (\n\t\t\t\t\t<ErrorDetails\n\t\t\t\t\t\terror={ error }\n\t\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t\t/>\n\t\t\t\t) : null }\n\t\t\t</Stack>\n\t\t);\n\t}\n}\n"],
5
- "mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AAEnB,SAAS,MAAM,iBAAiB,QAAQ,OAAO,YAAY;AAC3D,SAAS,0BAA0B;AACnC,SAAS,gBAAgB;AAoEvB,cAeG,YAfH;AAjEF,SAAS,aAAc,OAAQ;AAC9B,SAAS,iBAAiB,SAAS,MAAM,QAAU;AACpD;AAEA,SAAS,gBAAiB,OAAQ;AACjC,MAAK,OAAO,UAAU,YAAY,OAAQ;AACzC,WAAO;AAAA,EACR;AAEA,MAAK,OAAO,OAAO,YAAY,YAAY,MAAM,SAAU;AAC1D,WAAO,MAAM;AAAA,EACd;AAEA,SAAO;AACR;AAKA,SAAS,iBAAkB,OAAO,gBAAiB;AAClD,QAAM,WAAW;AAAA,IAChB,EAAE,OAAO,aAAc,KAAM,GAAG,SAAS,gBAAiB,KAAM,EAAE;AAAA,EACnE;AAEA,MAAK,OAAO,OAAQ;AACnB,aAAS,KAAM;AAAA,MACd,OAAO;AAAA,MACP,SAAS,MAAM,MAAM,KAAK;AAAA,MAC1B,cAAc;AAAA,IACf,CAAE;AAAA,EACH;AAEA,MAAK,gBAAiB;AACrB,aAAS,KAAM;AAAA,MACd,OAAO;AAAA,MACP,SAAS,eAAe,KAAK;AAAA,MAC7B,cAAc;AAAA,IACf,CAAE;AAAA,EACH;AAEA,WAAS,KAAM;AAAA,IACd,OAAO;AAAA,IACP,SAAS,eAAgB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AO,GAAG,SAAU;AAEpB,SAAK,QAAQ;AAAA,MACZ,OAAO;AAAA,MACP,gBAAgB;AAAA,IACjB;AAAA,EACD;AAAA,EAEA,kBAAmB,OAAO,WAAY;AACrC,SAAK,SAAU,EAAE,gBAAgB,WAAW,eAAe,CAAE;AAC7D,aAAU,oCAAoC,OAAO,SAAU;AAAA,EAChE;AAAA,EAEA,OAAO,yBAA0B,OAAQ;AACxC,WAAO,EAAE,MAAM;AAAA,EAChB;AAAA,EAEA,SAAS;AACR,UAAM,EAAE,OAAO,eAAe,IAAI,KAAK;AACvC,QAAK,CAAE,OAAQ;AACd,aAAO,KAAK,MAAM;AAAA,IACnB;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,WAAU;AAAA,QACV,KAAI;AAAA,QAEJ;AAAA,+BAAC,OAAO,MAAP,EAAY,QAAO,SACnB;AAAA,gCAAC,OAAO,OAAP,EACE,aAAI,wBAAyB,GAChC;AAAA,YACA,oBAAC,OAAO,aAAP,EACE;AAAA,cACD;AAAA,YACD,GACD;AAAA,YACA,oBAAC,OAAO,SAAP,EACA;AAAA,cAAC;AAAA;AAAA,gBACA,SAAQ;AAAA,gBACR,MAAO,MACN,eAAgB,OAAO,cAAe;AAAA,gBAGrC,aAAI,YAAa;AAAA;AAAA,YACpB,GACD;AAAA,aACD;AAAA,UACE,WAAW,eACZ;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA;AAAA,UACD,IACG;AAAA;AAAA;AAAA,IACL;AAAA,EAEF;AACD;",
4
+ "sourcesContent": ["import { Component } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\nimport { __ } from '@wordpress/i18n';\nimport { Card, CollapsibleCard, Notice, Stack, Text } from '@wordpress/ui';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { doAction } from '@wordpress/hooks';\n\nfunction getErrorNotice() {\n\treturn {\n\t\ttitle: __( 'The editor has crashed' ),\n\t\tdescription: __(\n\t\t\t'An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.'\n\t\t),\n\t};\n}\n\n// A boundary catches whatever was thrown, which is not always an `Error`.\nfunction getErrorName( error ) {\n\treturn ( error instanceof Error && error.name ) || 'Error';\n}\n\nfunction getErrorMessage( error ) {\n\tif ( typeof error === 'string' && error ) {\n\t\treturn error;\n\t}\n\n\tif ( typeof error?.message === 'string' && error.message ) {\n\t\treturn error.message;\n\t}\n\n\treturn 'An unknown error occurred.';\n}\n\n// The sections of the report, shared by the copied Markdown and the details\n// panel so that the two cannot drift apart. Deliberately untranslated: both\n// are developer-facing, and the report is pasted into a bug report.\nfunction getErrorSections( error, componentStack ) {\n\tconst sections = [\n\t\t{ label: getErrorName( error ), content: getErrorMessage( error ) },\n\t];\n\n\tif ( error?.stack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Stack',\n\t\t\tcontent: error.stack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tif ( componentStack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Component stack',\n\t\t\tcontent: componentStack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tsections.push( {\n\t\tlabel: 'Environment',\n\t\tcontent: `User agent: ${ window.navigator.userAgent }`,\n\t\tpreformatted: true,\n\t} );\n\n\treturn sections;\n}\n\n// Markdown, so the report stays readable as plain text and renders when pasted\n// into a bug report.\nfunction getErrorReport( error, componentStack ) {\n\tconst sections = getErrorSections( error, componentStack ).map(\n\t\t( { label, content, preformatted } ) =>\n\t\t\t`**${ label }**\\n\\n${\n\t\t\t\tpreformatted ? `\\`\\`\\`\\n${ content }\\n\\`\\`\\`` : content\n\t\t\t}`\n\t);\n\n\treturn [ '### Error report', ...sections ].join( '\\n\\n' );\n}\n\nfunction CopyButton( { text, children, variant = 'outline' } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Notice.ActionButton variant={ variant } ref={ ref }>\n\t\t\t{ children }\n\t\t</Notice.ActionButton>\n\t);\n}\n\nfunction ErrorReport( { error, componentStack } ) {\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"customize-widgets-error-boundary__report\"\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"md\"\n\t\t>\n\t\t\t{ getErrorSections( error, componentStack ).map(\n\t\t\t\t( { label, content } ) => (\n\t\t\t\t\t<Stack key={ label } direction=\"column\" gap=\"xs\">\n\t\t\t\t\t\t<Text variant=\"heading-md\">{ label }</Text>\n\t\t\t\t\t\t<pre className=\"customize-widgets-error-boundary__report-section\">\n\t\t\t\t\t\t\t{ content }\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t</Stack>\n\t\t\t\t)\n\t\t\t) }\n\t\t</Stack>\n\t);\n}\n\nfunction ErrorDetails( { error, componentStack } ) {\n\treturn (\n\t\t<CollapsibleCard.Root className=\"customize-widgets-error-boundary__details\">\n\t\t\t<CollapsibleCard.Header>\n\t\t\t\t<Card.Title>{ __( 'Error details' ) }</Card.Title>\n\t\t\t</CollapsibleCard.Header>\n\t\t\t<CollapsibleCard.Content>\n\t\t\t\t<ErrorReport\n\t\t\t\t\terror={ error }\n\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t/>\n\t\t\t</CollapsibleCard.Content>\n\t\t</CollapsibleCard.Root>\n\t);\n}\n\nexport default class ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t\tcomponentStack: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error, errorInfo ) {\n\t\tconst { title, description } = getErrorNotice();\n\t\tspeak( `${ title }. ${ description }`, 'assertive' );\n\t\tthis.setState( { componentStack: errorInfo?.componentStack } );\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error, errorInfo );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tconst { error, componentStack } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\tconst { title, description } = getErrorNotice();\n\n\t\treturn (\n\t\t\t<Stack\n\t\t\t\tclassName=\"customize-widgets-error-boundary\"\n\t\t\t\tdirection=\"column\"\n\t\t\t\tgap=\"lg\"\n\t\t\t>\n\t\t\t\t<Notice.Root intent=\"error\">\n\t\t\t\t\t<Notice.Title>{ title }</Notice.Title>\n\t\t\t\t\t<Notice.Description>{ description }</Notice.Description>\n\t\t\t\t\t<Notice.Actions>\n\t\t\t\t\t\t<CopyButton\n\t\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\t\ttext={ () =>\n\t\t\t\t\t\t\t\tgetErrorReport( error, componentStack )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Copy error' ) }\n\t\t\t\t\t\t</CopyButton>\n\t\t\t\t\t</Notice.Actions>\n\t\t\t\t</Notice.Root>\n\t\t\t\t{ globalThis.SCRIPT_DEBUG ? (\n\t\t\t\t\t<ErrorDetails\n\t\t\t\t\t\terror={ error }\n\t\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t\t/>\n\t\t\t\t) : null }\n\t\t\t</Stack>\n\t\t);\n\t}\n}\n"],
5
+ "mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,UAAU;AACnB,SAAS,MAAM,iBAAiB,QAAQ,OAAO,YAAY;AAC3D,SAAS,0BAA0B;AACnC,SAAS,gBAAgB;AA6EvB,cAeG,YAfH;AA3EF,SAAS,iBAAiB;AACzB,SAAO;AAAA,IACN,OAAO,GAAI,wBAAyB;AAAA,IACpC,aAAa;AAAA,MACZ;AAAA,IACD;AAAA,EACD;AACD;AAGA,SAAS,aAAc,OAAQ;AAC9B,SAAS,iBAAiB,SAAS,MAAM,QAAU;AACpD;AAEA,SAAS,gBAAiB,OAAQ;AACjC,MAAK,OAAO,UAAU,YAAY,OAAQ;AACzC,WAAO;AAAA,EACR;AAEA,MAAK,OAAO,OAAO,YAAY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O,OAAP,EAAe,iBAAO;AAAA,YACvB,oBAAC,OAAO,aAAP,EAAqB,uBAAa;AAAA,YACnC,oBAAC,OAAO,SAAP,EACA;AAAA,cAAC;AAAA;AAAA,gBACA,SAAQ;AAAA,gBACR,MAAO,MACN,eAAgB,OAAO,cAAe;AAAA,gBAGrC,aAAI,YAAa;AAAA;AAAA,YACpB,GACD;AAAA,aACD;AAAA,UACE,WAAW,eACZ;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA;AAAA,UACD,IACG;AAAA;AAAA;AAAA,IACL;AAAA,EAEF;AACD;",
6
6
  "names": []
7
7
  }
@@ -98,6 +98,21 @@
98
98
  --wp-block-synced-color--rgb: 122, 0, 223;
99
99
  --wp-bound-block-color: var(--wp-block-synced-color);
100
100
  --wp-editor-canvas-background: #ddd;
101
+ --wp-admin-theme-color: #3858e9;
102
+ --wp-admin-theme-color--rgb: 56, 88, 233;
103
+ --wp-admin-theme-color-darker-10: rgb(33.0384615385, 68.7307692308, 230.4615384615);
104
+ --wp-admin-theme-color-darker-10--rgb: 33.0384615385, 68.7307692308, 230.4615384615;
105
+ --wp-admin-theme-color-darker-20: rgb(23.6923076923, 58.1538461538, 214.3076923077);
106
+ --wp-admin-theme-color-darker-20--rgb: 23.6923076923, 58.1538461538, 214.3076923077;
107
+ --wp-admin-border-width-focus: 2px;
108
+ }
109
+ @media (min-resolution: 192dpi) {
110
+ :root {
111
+ --wp-admin-border-width-focus: 1.5px;
112
+ }
113
+ }
114
+
115
+ body.admin-color-fresh {
101
116
  --wp-admin-theme-color: #007cba;
102
117
  --wp-admin-theme-color--rgb: 0, 124, 186;
103
118
  --wp-admin-theme-color-darker-10: rgb(0, 107, 160.5);
@@ -107,7 +122,7 @@
107
122
  --wp-admin-border-width-focus: 2px;
108
123
  }
109
124
  @media (min-resolution: 192dpi) {
110
- :root {
125
+ body.admin-color-fresh {
111
126
  --wp-admin-border-width-focus: 1.5px;
112
127
  }
113
128
  }
@@ -98,6 +98,21 @@
98
98
  --wp-block-synced-color--rgb: 122, 0, 223;
99
99
  --wp-bound-block-color: var(--wp-block-synced-color);
100
100
  --wp-editor-canvas-background: #ddd;
101
+ --wp-admin-theme-color: #3858e9;
102
+ --wp-admin-theme-color--rgb: 56, 88, 233;
103
+ --wp-admin-theme-color-darker-10: rgb(33.0384615385, 68.7307692308, 230.4615384615);
104
+ --wp-admin-theme-color-darker-10--rgb: 33.0384615385, 68.7307692308, 230.4615384615;
105
+ --wp-admin-theme-color-darker-20: rgb(23.6923076923, 58.1538461538, 214.3076923077);
106
+ --wp-admin-theme-color-darker-20--rgb: 23.6923076923, 58.1538461538, 214.3076923077;
107
+ --wp-admin-border-width-focus: 2px;
108
+ }
109
+ @media (min-resolution: 192dpi) {
110
+ :root {
111
+ --wp-admin-border-width-focus: 1.5px;
112
+ }
113
+ }
114
+
115
+ body.admin-color-fresh {
101
116
  --wp-admin-theme-color: #007cba;
102
117
  --wp-admin-theme-color--rgb: 0, 124, 186;
103
118
  --wp-admin-theme-color-darker-10: rgb(0, 107, 160.5);
@@ -107,7 +122,7 @@
107
122
  --wp-admin-border-width-focus: 2px;
108
123
  }
109
124
  @media (min-resolution: 192dpi) {
110
- :root {
125
+ body.admin-color-fresh {
111
126
  --wp-admin-border-width-focus: 1.5px;
112
127
  }
113
128
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/customize-widgets",
3
- "version": "5.56.0",
3
+ "version": "5.57.0",
4
4
  "description": "Widgets blocks in Customizer Module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -38,29 +38,30 @@
38
38
  },
39
39
  "wpScript": true,
40
40
  "dependencies": {
41
- "@wordpress/admin-ui": "^2.11.0",
42
- "@wordpress/base-styles": "^13.2.0",
43
- "@wordpress/block-editor": "^18.0.0",
44
- "@wordpress/block-library": "^11.1.0",
45
- "@wordpress/blocks": "^16.1.0",
46
- "@wordpress/components": "^41.0.0",
47
- "@wordpress/compose": "^8.9.0",
48
- "@wordpress/core-data": "^8.1.0",
49
- "@wordpress/data": "^10.56.0",
50
- "@wordpress/dom": "^4.56.0",
51
- "@wordpress/element": "^8.8.0",
52
- "@wordpress/hooks": "^4.56.0",
53
- "@wordpress/i18n": "^6.29.0",
54
- "@wordpress/icons": "^17.0.0",
55
- "@wordpress/is-shallow-equal": "^5.56.0",
56
- "@wordpress/keyboard-shortcuts": "^5.56.0",
57
- "@wordpress/keycodes": "^4.56.0",
58
- "@wordpress/media-utils": "^5.56.0",
59
- "@wordpress/preferences": "^4.56.0",
60
- "@wordpress/private-apis": "^1.56.0",
61
- "@wordpress/theme": "^2.2.0",
62
- "@wordpress/ui": "^0.23.0",
63
- "@wordpress/widgets": "^4.56.0",
41
+ "@wordpress/a11y": "^4.57.0",
42
+ "@wordpress/admin-ui": "^2.12.0",
43
+ "@wordpress/base-styles": "^13.3.0",
44
+ "@wordpress/block-editor": "^18.1.0",
45
+ "@wordpress/block-library": "^11.2.0",
46
+ "@wordpress/blocks": "^16.2.0",
47
+ "@wordpress/components": "^42.0.0",
48
+ "@wordpress/compose": "^8.10.0",
49
+ "@wordpress/core-data": "^8.2.0",
50
+ "@wordpress/data": "^10.57.0",
51
+ "@wordpress/dom": "^4.57.0",
52
+ "@wordpress/element": "^9.0.0",
53
+ "@wordpress/hooks": "^4.57.0",
54
+ "@wordpress/i18n": "^6.30.0",
55
+ "@wordpress/icons": "^18.0.0",
56
+ "@wordpress/is-shallow-equal": "^5.57.0",
57
+ "@wordpress/keyboard-shortcuts": "^5.57.0",
58
+ "@wordpress/keycodes": "^4.57.0",
59
+ "@wordpress/media-utils": "^5.57.0",
60
+ "@wordpress/preferences": "^4.57.0",
61
+ "@wordpress/private-apis": "^2.0.0",
62
+ "@wordpress/theme": "^2.3.0",
63
+ "@wordpress/ui": "^0.24.0",
64
+ "@wordpress/widgets": "^4.57.0",
64
65
  "clsx": "^2.1.1",
65
66
  "fast-deep-equal": "^3.1.3"
66
67
  },
@@ -68,7 +69,7 @@
68
69
  "@testing-library/dom": "^10.4.2",
69
70
  "@testing-library/react": "^16.3.3",
70
71
  "@testing-library/user-event": "^14.6.1",
71
- "vitest": "^5.0.0"
72
+ "vitest": "^5.0.3"
72
73
  },
73
74
  "peerDependencies": {
74
75
  "react": "^18 || ^19",
@@ -77,5 +78,5 @@
77
78
  "publishConfig": {
78
79
  "access": "public"
79
80
  },
80
- "gitHead": "56d8058eda6e30c4cc8bfc37818fa6ed972f7dc2"
81
+ "gitHead": "12441e2520c78b2254a792a8cba40c34110be060"
81
82
  }
@@ -1,10 +1,19 @@
1
1
  import { Component } from '@wordpress/element';
2
+ import { speak } from '@wordpress/a11y';
2
3
  import { __ } from '@wordpress/i18n';
3
- // eslint-disable-next-line @wordpress/use-recommended-components -- The fallback UI renders outside the editor's notice system.
4
4
  import { Card, CollapsibleCard, Notice, Stack, Text } from '@wordpress/ui';
5
5
  import { useCopyToClipboard } from '@wordpress/compose';
6
6
  import { doAction } from '@wordpress/hooks';
7
7
 
8
+ function getErrorNotice() {
9
+ return {
10
+ title: __( 'The editor has crashed' ),
11
+ description: __(
12
+ 'An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.'
13
+ ),
14
+ };
15
+ }
16
+
8
17
  // A boundary catches whatever was thrown, which is not always an `Error`.
9
18
  function getErrorName( error ) {
10
19
  return ( error instanceof Error && error.name ) || 'Error';
@@ -125,6 +134,8 @@ export default class ErrorBoundary extends Component {
125
134
  }
126
135
 
127
136
  componentDidCatch( error, errorInfo ) {
137
+ const { title, description } = getErrorNotice();
138
+ speak( `${ title }. ${ description }`, 'assertive' );
128
139
  this.setState( { componentStack: errorInfo?.componentStack } );
129
140
  doAction( 'editor.ErrorBoundary.errorLogged', error, errorInfo );
130
141
  }
@@ -139,6 +150,8 @@ export default class ErrorBoundary extends Component {
139
150
  return this.props.children;
140
151
  }
141
152
 
153
+ const { title, description } = getErrorNotice();
154
+
142
155
  return (
143
156
  <Stack
144
157
  className="customize-widgets-error-boundary"
@@ -146,14 +159,8 @@ export default class ErrorBoundary extends Component {
146
159
  gap="lg"
147
160
  >
148
161
  <Notice.Root intent="error">
149
- <Notice.Title>
150
- { __( 'The editor has crashed' ) }
151
- </Notice.Title>
152
- <Notice.Description>
153
- { __(
154
- 'An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.'
155
- ) }
156
- </Notice.Description>
162
+ <Notice.Title>{ title }</Notice.Title>
163
+ <Notice.Description>{ description }</Notice.Description>
157
164
  <Notice.Actions>
158
165
  <CopyButton
159
166
  variant="solid"
@@ -1,8 +1,11 @@
1
1
  import { describe, expect, it, vi } from 'vitest';
2
- import { render } from '@testing-library/react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { speak } from '@wordpress/a11y';
3
4
  import * as wpHooks from '@wordpress/hooks';
4
5
  import ErrorBoundary from '../index';
5
6
 
7
+ vi.mock( import( '@wordpress/a11y' ), () => ( { speak: vi.fn() } ) );
8
+
6
9
  const theError = new Error( 'Kaboom' );
7
10
 
8
11
  const ChildComponent = () => {
@@ -11,6 +14,25 @@ const ChildComponent = () => {
11
14
 
12
15
  describe( 'Error Boundary', () => {
13
16
  describe( 'when error is thrown from a Child component', () => {
17
+ it( 'announces the error title and description without action labels', () => {
18
+ render(
19
+ <ErrorBoundary>
20
+ <ChildComponent />
21
+ </ErrorBoundary>
22
+ );
23
+
24
+ expect( console ).toHaveErrored();
25
+ expect( speak ).toHaveBeenCalledExactlyOnceWith(
26
+ 'The editor has crashed. An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.',
27
+ 'assertive'
28
+ );
29
+ expect( screen.queryByRole( 'alert' ) ).not.toBeInTheDocument();
30
+ const copyError = screen.getByRole( 'button', {
31
+ name: 'Copy error',
32
+ } );
33
+ expect( copyError ).toBeVisible();
34
+ } );
35
+
14
36
  it( 'calls the `editor.ErrorBoundary.errorLogged` hook action with the error object and error info', () => {
15
37
  const doAction = vi.spyOn( wpHooks, 'doAction' );
16
38