@wordpress/customize-widgets 5.56.0 → 6.0.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.
@@ -36,6 +36,7 @@ var import_admin_ui = require("@wordpress/admin-ui");
36
36
  var import_element = require("@wordpress/element");
37
37
  var import_components = require("@wordpress/components");
38
38
  var import_theme = require("@wordpress/theme");
39
+ var import_ui = require("@wordpress/ui");
39
40
  var import_error_boundary = __toESM(require("../error-boundary/index.cjs"));
40
41
  var import_sidebar_block_editor = __toESM(require("../sidebar-block-editor/index.cjs"));
41
42
  var import_focus_control = __toESM(require("../focus-control/index.cjs"));
@@ -53,6 +54,7 @@ function CustomizeWidgets({
53
54
  );
54
55
  const popoverRef = (0, import_element.useRef)();
55
56
  const adminPrimary = (0, import_element.useMemo)(() => (0, import_admin_ui.getAdminThemeColors)().primary, []);
57
+ (0, import_ui.useEnableWpCompatOverlaySlot)();
56
58
  (0, import_use_clear_selected_block.default)(activeSidebarControl, popoverRef);
57
59
  (0, import_element.useEffect)(() => {
58
60
  const unsubscribers = sidebarControls.map(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/customize-widgets/index.jsx"],
4
- "sourcesContent": ["import { getAdminThemeColors } from '@wordpress/admin-ui';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tcreatePortal,\n\tuseMemo,\n} from '@wordpress/element';\nimport { SlotFillProvider, Popover } from '@wordpress/components';\nimport { ThemeProvider } from '@wordpress/theme';\nimport ErrorBoundary from '../error-boundary';\nimport SidebarBlockEditor from '../sidebar-block-editor';\nimport FocusControl from '../focus-control';\nimport SidebarControls from '../sidebar-controls';\nimport useClearSelectedBlock from './use-clear-selected-block';\n\nexport default function CustomizeWidgets( {\n\tapi,\n\tsidebarControls,\n\tblockEditorSettings,\n} ) {\n\tconst [ activeSidebarControl, setActiveSidebarControl ] = useState( null );\n\tconst parentContainer = document.getElementById(\n\t\t'customize-theme-controls'\n\t);\n\tconst popoverRef = useRef();\n\tconst adminPrimary = useMemo( () => getAdminThemeColors().primary, [] );\n\n\tuseClearSelectedBlock( activeSidebarControl, popoverRef );\n\n\tuseEffect( () => {\n\t\tconst unsubscribers = sidebarControls.map( ( sidebarControl ) =>\n\t\t\tsidebarControl.subscribe( ( expanded ) => {\n\t\t\t\tif ( expanded ) {\n\t\t\t\t\tsetActiveSidebarControl( sidebarControl );\n\t\t\t\t}\n\t\t\t} )\n\t\t);\n\n\t\treturn () => {\n\t\t\tunsubscribers.forEach( ( unsubscriber ) => unsubscriber() );\n\t\t};\n\t}, [ sidebarControls ] );\n\n\tconst activeSidebar =\n\t\tactiveSidebarControl &&\n\t\tcreatePortal(\n\t\t\t<ErrorBoundary>\n\t\t\t\t<SidebarBlockEditor\n\t\t\t\t\tkey={ activeSidebarControl.id }\n\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\tsidebar={ activeSidebarControl.sidebarAdapter }\n\t\t\t\t\tinserter={ activeSidebarControl.inserter }\n\t\t\t\t\tinspector={ activeSidebarControl.inspector }\n\t\t\t\t/>\n\t\t\t</ErrorBoundary>,\n\t\t\tactiveSidebarControl.container[ 0 ]\n\t\t);\n\n\t// We have to portal this to the parent of both the editor and the inspector,\n\t// so that the popovers will appear above both of them.\n\tconst popover =\n\t\tparentContainer &&\n\t\tcreatePortal(\n\t\t\t<div className=\"customize-widgets-popover\" ref={ popoverRef }>\n\t\t\t\t<Popover.Slot />\n\t\t\t</div>,\n\t\t\tparentContainer\n\t\t);\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ThemeProvider isRoot color={ { primary: adminPrimary } }>\n\t\t\t\t<SidebarControls\n\t\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t\t\tactiveSidebarControl={ activeSidebarControl }\n\t\t\t\t>\n\t\t\t\t\t<FocusControl\n\t\t\t\t\t\tapi={ api }\n\t\t\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t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ACnC;AAID,QAAM,UACL,uBACA;AAAA,IACC,4CAAC,SAAI,WAAU,6BAA4B,KAAM,YAChD,sDAAC,0BAAQ,MAAR,EAAa,GACf;AAAA,IACA;AAAA,EACD;AAED,SACC,4CAAC,sCACA,sDAAC,8BAAc,QAAM,MAAC,OAAQ,EAAE,SAAS,aAAa,GACrD;AAAA,IAAC,wBAAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,QAAC,qBAAAC;AAAA,QAAA;AAAA,UACA;AAAA,UACA;AAAA,UAEE;AAAA;AAAA,YACA;AAAA;AAAA;AAAA,MACH;AAAA;AAAA,EACD,GACD,GACD;AAEF;",
4
+ "sourcesContent": ["import { getAdminThemeColors } from '@wordpress/admin-ui';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tcreatePortal,\n\tuseMemo,\n} from '@wordpress/element';\nimport { SlotFillProvider, Popover } from '@wordpress/components';\nimport { ThemeProvider } from '@wordpress/theme';\nimport { useEnableWpCompatOverlaySlot } from '@wordpress/ui';\nimport ErrorBoundary from '../error-boundary';\nimport SidebarBlockEditor from '../sidebar-block-editor';\nimport FocusControl from '../focus-control';\nimport SidebarControls from '../sidebar-controls';\nimport useClearSelectedBlock from './use-clear-selected-block';\n\nexport default function CustomizeWidgets( {\n\tapi,\n\tsidebarControls,\n\tblockEditorSettings,\n} ) {\n\tconst [ activeSidebarControl, setActiveSidebarControl ] = useState( null );\n\tconst parentContainer = document.getElementById(\n\t\t'customize-theme-controls'\n\t);\n\tconst popoverRef = useRef();\n\tconst adminPrimary = useMemo( () => getAdminThemeColors().primary, [] );\n\n\t// `useClearSelectedBlock` relies on the slot marker to spot overlays.\n\tuseEnableWpCompatOverlaySlot();\n\tuseClearSelectedBlock( activeSidebarControl, popoverRef );\n\n\tuseEffect( () => {\n\t\tconst unsubscribers = sidebarControls.map( ( sidebarControl ) =>\n\t\t\tsidebarControl.subscribe( ( expanded ) => {\n\t\t\t\tif ( expanded ) {\n\t\t\t\t\tsetActiveSidebarControl( sidebarControl );\n\t\t\t\t}\n\t\t\t} )\n\t\t);\n\n\t\treturn () => {\n\t\t\tunsubscribers.forEach( ( unsubscriber ) => unsubscriber() );\n\t\t};\n\t}, [ sidebarControls ] );\n\n\tconst activeSidebar =\n\t\tactiveSidebarControl &&\n\t\tcreatePortal(\n\t\t\t<ErrorBoundary>\n\t\t\t\t<SidebarBlockEditor\n\t\t\t\t\tkey={ activeSidebarControl.id }\n\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\tsidebar={ activeSidebarControl.sidebarAdapter }\n\t\t\t\t\tinserter={ activeSidebarControl.inserter }\n\t\t\t\t\tinspector={ activeSidebarControl.inspector }\n\t\t\t\t/>\n\t\t\t</ErrorBoundary>,\n\t\t\tactiveSidebarControl.container[ 0 ]\n\t\t);\n\n\t// We have to portal this to the parent of both the editor and the inspector,\n\t// so that the popovers will appear above both of them.\n\tconst popover =\n\t\tparentContainer &&\n\t\tcreatePortal(\n\t\t\t<div className=\"customize-widgets-popover\" ref={ popoverRef }>\n\t\t\t\t<Popover.Slot />\n\t\t\t</div>,\n\t\t\tparentContainer\n\t\t);\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ThemeProvider isRoot color={ { primary: adminPrimary } }>\n\t\t\t\t<SidebarControls\n\t\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t\t\tactiveSidebarControl={ activeSidebarControl }\n\t\t\t\t>\n\t\t\t\t\t<FocusControl\n\t\t\t\t\t\tapi={ api }\n\t\t\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ activeSidebar }\n\t\t\t\t\t\t{ popover }\n\t\t\t\t\t</FocusControl>\n\t\t\t\t</SidebarControls>\n\t\t\t</ThemeProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,s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rD;AAAA,IAAC,wBAAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,QAAC,qBAAAC;AAAA,QAAA;AAAA,UACA;AAAA,UACA;AAAA,UAEE;AAAA;AAAA,YACA;AAAA;AAAA;AAAA,MACH;AAAA;AAAA,EACD,GACD,GACD;AAEF;",
6
6
  "names": ["useClearSelectedBlock", "ErrorBoundary", "SidebarBlockEditor", "SidebarControls", "FocusControl"]
7
7
  }
@@ -35,7 +35,7 @@ function useClearSelectedBlock(sidebarControl, popoverRef) {
35
35
  // 1. Make sure there are blocks being selected.
36
36
  (hasSelectedBlock() || hasMultiSelection()) && // 2. The element should exist in the DOM (not deleted).
37
37
  element && ownerDocument.contains(element) && // 3. It should also not exist in the container, the popover, nor the dialog.
38
- !container.contains(element) && !popoverRef.current.contains(element) && !element.closest('[role="dialog"]') && // 4. The inspector should not be opened.
38
+ !container.contains(element) && !popoverRef.current.contains(element) && !element.closest("[data-wp-compat-overlay-slot]") && !element.closest('[role="dialog"]') && // 4. The inspector should not be opened.
39
39
  !inspector.expanded()
40
40
  ) {
41
41
  clearSelectedBlock();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/customize-widgets/use-clear-selected-block.js"],
4
- "sourcesContent": ["import { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * We can't just use <BlockSelectionClearer> because the customizer has\n * many root nodes rather than just one in the post editor.\n * We need to listen to the focus events in all those roots, and also in\n * the preview iframe.\n * This hook will clear the selected block when focusing outside the editor,\n * with a few exceptions:\n * 1. Focusing on popovers.\n * 2. Focusing on the inspector.\n * 3. Focusing on any modals/dialogs.\n * These cases are normally triggered by user interactions from the editor,\n * not by explicitly focusing outside the editor, hence no need for clearing.\n *\n * @param {Object} sidebarControl The sidebar control instance.\n * @param {Object} popoverRef The ref object of the popover node container.\n */\nexport default function useClearSelectedBlock( sidebarControl, popoverRef ) {\n\tconst { hasSelectedBlock, hasMultiSelection } =\n\t\tuseSelect( blockEditorStore );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( popoverRef.current && sidebarControl ) {\n\t\t\tconst inspector = sidebarControl.inspector;\n\t\t\tconst container = sidebarControl.container[ 0 ];\n\t\t\tconst ownerDocument = container.ownerDocument;\n\t\t\tconst ownerWindow = ownerDocument.defaultView;\n\n\t\t\tfunction handleClearSelectedBlock( element ) {\n\t\t\t\tif (\n\t\t\t\t\t// 1. Make sure there are blocks being selected.\n\t\t\t\t\t( hasSelectedBlock() || hasMultiSelection() ) &&\n\t\t\t\t\t// 2. The element should exist in the DOM (not deleted).\n\t\t\t\t\telement &&\n\t\t\t\t\townerDocument.contains( element ) &&\n\t\t\t\t\t// 3. It should also not exist in the container, the popover, nor the dialog.\n\t\t\t\t\t! container.contains( element ) &&\n\t\t\t\t\t! popoverRef.current.contains( element ) &&\n\t\t\t\t\t! element.closest( '[role=\"dialog\"]' ) &&\n\t\t\t\t\t// 4. The inspector should not be opened.\n\t\t\t\t\t! inspector.expanded()\n\t\t\t\t) {\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Handle mouse down in the same document.\n\t\t\tfunction handleMouseDown( event ) {\n\t\t\t\thandleClearSelectedBlock( event.target );\n\t\t\t}\n\t\t\t// Handle focusing outside the current document, like to iframes.\n\t\t\tfunction handleBlur() {\n\t\t\t\thandleClearSelectedBlock( ownerDocument.activeElement );\n\t\t\t}\n\n\t\t\townerDocument.addEventListener( 'mousedown', handleMouseDown );\n\t\t\townerWindow.addEventListener( 'blur', handleBlur );\n\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'mousedown',\n\t\t\t\t\thandleMouseDown\n\t\t\t\t);\n\t\t\t\townerWindow.removeEventListener( 'blur', handleBlur );\n\t\t\t};\n\t\t}\n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AA,IACA;AAAA,EACD,CAAE;AACH;",
4
+ "sourcesContent": ["import { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * We can't just use <BlockSelectionClearer> because the customizer has\n * many root nodes rather than just one in the post editor.\n * We need to listen to the focus events in all those roots, and also in\n * the preview iframe.\n * This hook will clear the selected block when focusing outside the editor,\n * with a few exceptions:\n * 1. Focusing on popovers, including `@wordpress/ui` overlays.\n * 2. Focusing on the inspector.\n * 3. Focusing on any modals/dialogs.\n * These cases are normally triggered by user interactions from the editor,\n * not by explicitly focusing outside the editor, hence no need for clearing.\n *\n * @param {Object} sidebarControl The sidebar control instance.\n * @param {Object} popoverRef The ref object of the popover node container.\n */\nexport default function useClearSelectedBlock( sidebarControl, popoverRef ) {\n\tconst { hasSelectedBlock, hasMultiSelection } =\n\t\tuseSelect( blockEditorStore );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( popoverRef.current && sidebarControl ) {\n\t\t\tconst inspector = sidebarControl.inspector;\n\t\t\tconst container = sidebarControl.container[ 0 ];\n\t\t\tconst ownerDocument = container.ownerDocument;\n\t\t\tconst ownerWindow = ownerDocument.defaultView;\n\n\t\t\tfunction handleClearSelectedBlock( element ) {\n\t\t\t\tif (\n\t\t\t\t\t// 1. Make sure there are blocks being selected.\n\t\t\t\t\t( hasSelectedBlock() || hasMultiSelection() ) &&\n\t\t\t\t\t// 2. The element should exist in the DOM (not deleted).\n\t\t\t\t\telement &&\n\t\t\t\t\townerDocument.contains( element ) &&\n\t\t\t\t\t// 3. It should also not exist in the container, the popover, nor the dialog.\n\t\t\t\t\t! container.contains( element ) &&\n\t\t\t\t\t! popoverRef.current.contains( element ) &&\n\t\t\t\t\t! element.closest( '[data-wp-compat-overlay-slot]' ) &&\n\t\t\t\t\t! element.closest( '[role=\"dialog\"]' ) &&\n\t\t\t\t\t// 4. The inspector should not be opened.\n\t\t\t\t\t! inspector.expanded()\n\t\t\t\t) {\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Handle mouse down in the same document.\n\t\t\tfunction handleMouseDown( event ) {\n\t\t\t\thandleClearSelectedBlock( event.target );\n\t\t\t}\n\t\t\t// Handle focusing outside the current document, like to iframes.\n\t\t\tfunction handleBlur() {\n\t\t\t\thandleClearSelectedBlock( ownerDocument.activeElement );\n\t\t\t}\n\n\t\t\townerDocument.addEventListener( 'mousedown', handleMouseDown );\n\t\t\townerWindow.addEventListener( 'blur', handleBlur );\n\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'mousedown',\n\t\t\t\t\thandleMouseDown\n\t\t\t\t);\n\t\t\t\townerWindow.removeEventListener( 'blur', handleBlur );\n\t\t\t};\n\t\t}\n\t}, [\n\t\tpopoverRef,\n\t\tsidebarControl,\n\t\thasSelectedBlock,\n\t\thasMultiSelection,\n\t\tclearSelectedBlock,\n\t] );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA0B;AAC1B,kBAAuC;AACvC,0BAA0C;AAkB3B,SAAR,sBAAwC,gBAAgB,YAAa;AAC3E,QAAM,EAAE,kBAAkB,kBAAkB,QAC3C,uBAAW,oBAAAA,KAAiB;AAC7B,QAAM,EAAE,mBAAmB,QAAI,yBAAa,oBAAAA,KAAiB;AAE7D,gCAAW,MAAM;AAChB,QAAK,WAAW,WAAW,gBAAiB;AAM3C,UAAS,2BAAT,SAAmC,SAAU;AAC5C;AAAA;AAAA,WAEG,iBAAiB,KAAK,kBAAkB;AAAA,UAE1C,WACA,cAAc,SAAU,OAAQ;AAAA,UAEhC,CAAE,UAAU,SAAU,OAAQ,KAC9B,CAAE,WAAW,QAAQ,SAAU,OAAQ,KACvC,CAAE,QAAQ,QAAS,+BAAgC,KACnD,CAAE,QAAQ,QAAS,iBAAkB;AAAA,UAErC,CAAE,UAAU,SAAS;AAAA,UACpB;AACD,6BAAmB;AAAA,QACpB;AAAA,MACD,GAGS,kBAAT,SAA0B,OAAQ;AACjC,iCAA0B,MAAM,MAAO;AAAA,MACxC,GAES,aAAT,WAAsB;AACrB,iCAA0B,cAAc,aAAc;AAAA,MACvD;AA/BA,YAAM,YAAY,eAAe;AACjC,YAAM,YAAY,eAAe,UAAW,CAAE;AAC9C,YAAM,gBAAgB,UAAU;AAChC,YAAM,cAAc,cAAc;AA8BlC,oBAAc,iBAAkB,aAAa,eAAgB;AAC7D,kBAAY,iBAAkB,QAAQ,UAAW;AAEjD,aAAO,MAAM;AACZ,sBAAc;AAAA,UACb;AAAA,UACA;AAAA,QACD;AACA,oBAAY,oBAAqB,QAAQ,UAAW;AAAA,MACrD;AAAA,IACD;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
6
6
  "names": ["blockEditorStore"]
7
7
  }
@@ -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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,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;AAC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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,UAAM,EAAE,OAAO,YAAY,IAAI,eAAe;AAE9C,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,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
  }
@@ -9,6 +9,7 @@ import {
9
9
  } from "@wordpress/element";
10
10
  import { SlotFillProvider, Popover } from "@wordpress/components";
11
11
  import { ThemeProvider } from "@wordpress/theme";
12
+ import { useEnableWpCompatOverlaySlot } from "@wordpress/ui";
12
13
  import ErrorBoundary from "../error-boundary/index.mjs";
13
14
  import SidebarBlockEditor from "../sidebar-block-editor/index.mjs";
14
15
  import FocusControl from "../focus-control/index.mjs";
@@ -26,6 +27,7 @@ function CustomizeWidgets({
26
27
  );
27
28
  const popoverRef = useRef();
28
29
  const adminPrimary = useMemo(() => getAdminThemeColors().primary, []);
30
+ useEnableWpCompatOverlaySlot();
29
31
  useClearSelectedBlock(activeSidebarControl, popoverRef);
30
32
  useEffect(() => {
31
33
  const unsubscribers = sidebarControls.map(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/customize-widgets/index.jsx"],
4
- "sourcesContent": ["import { getAdminThemeColors } from '@wordpress/admin-ui';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tcreatePortal,\n\tuseMemo,\n} from '@wordpress/element';\nimport { SlotFillProvider, Popover } from '@wordpress/components';\nimport { ThemeProvider } from '@wordpress/theme';\nimport ErrorBoundary from '../error-boundary';\nimport SidebarBlockEditor from '../sidebar-block-editor';\nimport FocusControl from '../focus-control';\nimport SidebarControls from '../sidebar-controls';\nimport useClearSelectedBlock from './use-clear-selected-block';\n\nexport default function CustomizeWidgets( {\n\tapi,\n\tsidebarControls,\n\tblockEditorSettings,\n} ) {\n\tconst [ activeSidebarControl, setActiveSidebarControl ] = useState( null );\n\tconst parentContainer = document.getElementById(\n\t\t'customize-theme-controls'\n\t);\n\tconst popoverRef = useRef();\n\tconst adminPrimary = useMemo( () => getAdminThemeColors().primary, [] );\n\n\tuseClearSelectedBlock( activeSidebarControl, popoverRef );\n\n\tuseEffect( () => {\n\t\tconst unsubscribers = sidebarControls.map( ( sidebarControl ) =>\n\t\t\tsidebarControl.subscribe( ( expanded ) => {\n\t\t\t\tif ( expanded ) {\n\t\t\t\t\tsetActiveSidebarControl( sidebarControl );\n\t\t\t\t}\n\t\t\t} )\n\t\t);\n\n\t\treturn () => {\n\t\t\tunsubscribers.forEach( ( unsubscriber ) => unsubscriber() );\n\t\t};\n\t}, [ sidebarControls ] );\n\n\tconst activeSidebar =\n\t\tactiveSidebarControl &&\n\t\tcreatePortal(\n\t\t\t<ErrorBoundary>\n\t\t\t\t<SidebarBlockEditor\n\t\t\t\t\tkey={ activeSidebarControl.id }\n\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\tsidebar={ activeSidebarControl.sidebarAdapter }\n\t\t\t\t\tinserter={ activeSidebarControl.inserter }\n\t\t\t\t\tinspector={ activeSidebarControl.inspector }\n\t\t\t\t/>\n\t\t\t</ErrorBoundary>,\n\t\t\tactiveSidebarControl.container[ 0 ]\n\t\t);\n\n\t// We have to portal this to the parent of both the editor and the inspector,\n\t// so that the popovers will appear above both of them.\n\tconst popover =\n\t\tparentContainer &&\n\t\tcreatePortal(\n\t\t\t<div className=\"customize-widgets-popover\" ref={ popoverRef }>\n\t\t\t\t<Popover.Slot />\n\t\t\t</div>,\n\t\t\tparentContainer\n\t\t);\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ThemeProvider isRoot color={ { primary: adminPrimary } }>\n\t\t\t\t<SidebarControls\n\t\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t\t\tactiveSidebarControl={ activeSidebarControl }\n\t\t\t\t>\n\t\t\t\t\t<FocusControl\n\t\t\t\t\t\tapi={ api }\n\t\t\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ activeSidebar }\n\t\t\t\t\t\t{ popover }\n\t\t\t\t\t</FocusControl>\n\t\t\t\t</SidebarControls>\n\t\t\t</ThemeProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n"],
5
- "mappings": ";AAAA,SAAS,2BAA2B;AACpC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,kBAAkB,eAAe;AAC1C,SAAS,qBAAqB;AAC9B,OAAO,mBAAmB;AAC1B,OAAO,wBAAwB;AAC/B,OAAO,kBAAkB;AACzB,OAAO,qBAAqB;AAC5B,OAAO,2BAA2B;AAkC9B,cA6BC,YA7BD;AAhCW,SAAR,iBAAmC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,CAAE,sBAAsB,uBAAwB,IAAI,SAAU,IAAK;AACzE,QAAM,kBAAkB,SAAS;AAAA,IAChC;AAAA,EACD;AACA,QAAM,aAAa,OAAO;AAC1B,QAAM,eAAe,QAAS,MAAM,oBAAoB,EAAE,SAAS,CAAC,CAAE;AAEtE,wBAAuB,sBAAsB,UAAW;AAExD,YAAW,MAAM;AAChB,UAAM,gBAAgB,gBAAgB;AAAA,MAAK,CAAE,mBAC5C,eAAe,UAAW,CAAE,aAAc;AACzC,YAAK,UAAW;AACf,kCAAyB,cAAe;AAAA,QACzC;AAAA,MACD,CAAE;AAAA,IACH;AAEA,WAAO,MAAM;AACZ,oBAAc,QAAS,CAAE,iBAAkB,aAAa,CAAE;AAAA,IAC3D;AAAA,EACD,GAAG,CAAE,eAAgB,CAAE;AAEvB,QAAM,gBACL,wBACA;AAAA,IACC,oBAAC,iBACA;AAAA,MAAC;AAAA;AAAA,QAEA;AAAA,QACA,SAAU,qBAAqB;AAAA,QAC/B,UAAW,qBAAqB;AAAA,QAChC,WAAY,qBAAqB;AAAA;AAAA,MAJ3B,qBAAqB;AAAA,IAK5B,GACD;AAAA,IACA,qBAAqB,UAAW,CAAE;AAAA,EACnC;AAID,QAAM,UACL,mBACA;AAAA,IACC,oBAAC,SAAI,WAAU,6BAA4B,KAAM,YAChD,8BAAC,QAAQ,MAAR,EAAa,GACf;AAAA,IACA;AAAA,EACD;AAED,SACC,oBAAC,oBACA,8BAAC,iBAAc,QAAM,MAAC,OAAQ,EAAE,SAAS,aAAa,GACrD;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA;AAAA,UAEE;AAAA;AAAA,YACA;AAAA;AAAA;AAAA,MACH;AAAA;AAAA,EACD,GACD,GACD;AAEF;",
4
+ "sourcesContent": ["import { getAdminThemeColors } from '@wordpress/admin-ui';\nimport {\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tcreatePortal,\n\tuseMemo,\n} from '@wordpress/element';\nimport { SlotFillProvider, Popover } from '@wordpress/components';\nimport { ThemeProvider } from '@wordpress/theme';\nimport { useEnableWpCompatOverlaySlot } from '@wordpress/ui';\nimport ErrorBoundary from '../error-boundary';\nimport SidebarBlockEditor from '../sidebar-block-editor';\nimport FocusControl from '../focus-control';\nimport SidebarControls from '../sidebar-controls';\nimport useClearSelectedBlock from './use-clear-selected-block';\n\nexport default function CustomizeWidgets( {\n\tapi,\n\tsidebarControls,\n\tblockEditorSettings,\n} ) {\n\tconst [ activeSidebarControl, setActiveSidebarControl ] = useState( null );\n\tconst parentContainer = document.getElementById(\n\t\t'customize-theme-controls'\n\t);\n\tconst popoverRef = useRef();\n\tconst adminPrimary = useMemo( () => getAdminThemeColors().primary, [] );\n\n\t// `useClearSelectedBlock` relies on the slot marker to spot overlays.\n\tuseEnableWpCompatOverlaySlot();\n\tuseClearSelectedBlock( activeSidebarControl, popoverRef );\n\n\tuseEffect( () => {\n\t\tconst unsubscribers = sidebarControls.map( ( sidebarControl ) =>\n\t\t\tsidebarControl.subscribe( ( expanded ) => {\n\t\t\t\tif ( expanded ) {\n\t\t\t\t\tsetActiveSidebarControl( sidebarControl );\n\t\t\t\t}\n\t\t\t} )\n\t\t);\n\n\t\treturn () => {\n\t\t\tunsubscribers.forEach( ( unsubscriber ) => unsubscriber() );\n\t\t};\n\t}, [ sidebarControls ] );\n\n\tconst activeSidebar =\n\t\tactiveSidebarControl &&\n\t\tcreatePortal(\n\t\t\t<ErrorBoundary>\n\t\t\t\t<SidebarBlockEditor\n\t\t\t\t\tkey={ activeSidebarControl.id }\n\t\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t\t\tsidebar={ activeSidebarControl.sidebarAdapter }\n\t\t\t\t\tinserter={ activeSidebarControl.inserter }\n\t\t\t\t\tinspector={ activeSidebarControl.inspector }\n\t\t\t\t/>\n\t\t\t</ErrorBoundary>,\n\t\t\tactiveSidebarControl.container[ 0 ]\n\t\t);\n\n\t// We have to portal this to the parent of both the editor and the inspector,\n\t// so that the popovers will appear above both of them.\n\tconst popover =\n\t\tparentContainer &&\n\t\tcreatePortal(\n\t\t\t<div className=\"customize-widgets-popover\" ref={ popoverRef }>\n\t\t\t\t<Popover.Slot />\n\t\t\t</div>,\n\t\t\tparentContainer\n\t\t);\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ThemeProvider isRoot color={ { primary: adminPrimary } }>\n\t\t\t\t<SidebarControls\n\t\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t\t\tactiveSidebarControl={ activeSidebarControl }\n\t\t\t\t>\n\t\t\t\t\t<FocusControl\n\t\t\t\t\t\tapi={ api }\n\t\t\t\t\t\tsidebarControls={ sidebarControls }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ activeSidebar }\n\t\t\t\t\t\t{ popover }\n\t\t\t\t\t</FocusControl>\n\t\t\t\t</SidebarControls>\n\t\t\t</ThemeProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n"],
5
+ "mappings": ";AAAA,SAAS,2BAA2B;AACpC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,kBAAkB,eAAe;AAC1C,SAAS,qBAAqB;AAC9B,SAAS,oCAAoC;AAC7C,OAAO,mBAAmB;AAC1B,OAAO,wBAAwB;AAC/B,OAAO,kBAAkB;AACzB,OAAO,qBAAqB;AAC5B,OAAO,2BAA2B;AAoC9B,cA6BC,YA7BD;AAlCW,SAAR,iBAAmC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,CAAE,sBAAsB,uBAAwB,IAAI,SAAU,IAAK;AACzE,QAAM,kBAAkB,SAAS;AAAA,IAChC;AAAA,EACD;AACA,QAAM,aAAa,OAAO;AAC1B,QAAM,eAAe,QAAS,MAAM,oBAAoB,EAAE,SAAS,CAAC,CAAE;AAGtE,+BAA6B;AAC7B,wBAAuB,sBAAsB,UAAW;AAExD,YAAW,MAAM;AAChB,UAAM,gBAAgB,gBAAgB;AAAA,MAAK,CAAE,mBAC5C,eAAe,UAAW,CAAE,aAAc;AACzC,YAAK,UAAW;AACf,kCAAyB,cAAe;AAAA,QACzC;AAAA,MACD,CAAE;AAAA,IACH;AAEA,WAAO,MAAM;AACZ,oBAAc,QAAS,CAAE,iBAAkB,aAAa,CAAE;AAAA,IAC3D;AAAA,EACD,GAAG,CAAE,eAAgB,CAAE;AAEvB,QAAM,gBACL,wBACA;AAAA,IACC,oBAAC,iBACA;AAAA,MAAC;AAAA;AAAA,QAEA;AAAA,QACA,SAAU,qBAAqB;AAAA,QAC/B,UAAW,qBAAqB;AAAA,QAChC,WAAY,qBAAqB;AAAA;AAAA,MAJ3B,qBAAqB;AAAA,IAK5B,GACD;AAAA,IACA,qBAAqB,UAAW,CAAE;AAAA,EACnC;AAID,QAAM,UACL,mBACA;AAAA,IACC,oBAAC,SAAI,WAAU,6BAA4B,KAAM,YAChD,8BAAC,QAAQ,MAAR,EAAa,GACf;AAAA,IACA;AAAA,EACD;AAED,SACC,oBAAC,oBACA,8BAAC,iBAAc,QAAM,MAAC,OAAQ,EAAE,SAAS,aAAa,GACrD;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA;AAAA,UAEE;AAAA;AAAA,YACA;AAAA;AAAA;AAAA,MACH;AAAA;AAAA,EACD,GACD,GACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -12,7 +12,7 @@ function useClearSelectedBlock(sidebarControl, popoverRef) {
12
12
  // 1. Make sure there are blocks being selected.
13
13
  (hasSelectedBlock() || hasMultiSelection()) && // 2. The element should exist in the DOM (not deleted).
14
14
  element && ownerDocument.contains(element) && // 3. It should also not exist in the container, the popover, nor the dialog.
15
- !container.contains(element) && !popoverRef.current.contains(element) && !element.closest('[role="dialog"]') && // 4. The inspector should not be opened.
15
+ !container.contains(element) && !popoverRef.current.contains(element) && !element.closest("[data-wp-compat-overlay-slot]") && !element.closest('[role="dialog"]') && // 4. The inspector should not be opened.
16
16
  !inspector.expanded()
17
17
  ) {
18
18
  clearSelectedBlock();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/customize-widgets/use-clear-selected-block.js"],
4
- "sourcesContent": ["import { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * We can't just use <BlockSelectionClearer> because the customizer has\n * many root nodes rather than just one in the post editor.\n * We need to listen to the focus events in all those roots, and also in\n * the preview iframe.\n * This hook will clear the selected block when focusing outside the editor,\n * with a few exceptions:\n * 1. Focusing on popovers.\n * 2. Focusing on the inspector.\n * 3. Focusing on any modals/dialogs.\n * These cases are normally triggered by user interactions from the editor,\n * not by explicitly focusing outside the editor, hence no need for clearing.\n *\n * @param {Object} sidebarControl The sidebar control instance.\n * @param {Object} popoverRef The ref object of the popover node container.\n */\nexport default function useClearSelectedBlock( sidebarControl, popoverRef ) {\n\tconst { hasSelectedBlock, hasMultiSelection } =\n\t\tuseSelect( blockEditorStore );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( popoverRef.current && sidebarControl ) {\n\t\t\tconst inspector = sidebarControl.inspector;\n\t\t\tconst container = sidebarControl.container[ 0 ];\n\t\t\tconst ownerDocument = container.ownerDocument;\n\t\t\tconst ownerWindow = ownerDocument.defaultView;\n\n\t\t\tfunction handleClearSelectedBlock( element ) {\n\t\t\t\tif (\n\t\t\t\t\t// 1. Make sure there are blocks being selected.\n\t\t\t\t\t( hasSelectedBlock() || hasMultiSelection() ) &&\n\t\t\t\t\t// 2. The element should exist in the DOM (not deleted).\n\t\t\t\t\telement &&\n\t\t\t\t\townerDocument.contains( element ) &&\n\t\t\t\t\t// 3. It should also not exist in the container, the popover, nor the dialog.\n\t\t\t\t\t! container.contains( element ) &&\n\t\t\t\t\t! popoverRef.current.contains( element ) &&\n\t\t\t\t\t! element.closest( '[role=\"dialog\"]' ) &&\n\t\t\t\t\t// 4. The inspector should not be opened.\n\t\t\t\t\t! inspector.expanded()\n\t\t\t\t) {\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Handle mouse down in the same document.\n\t\t\tfunction handleMouseDown( event ) {\n\t\t\t\thandleClearSelectedBlock( event.target );\n\t\t\t}\n\t\t\t// Handle focusing outside the current document, like to iframes.\n\t\t\tfunction handleBlur() {\n\t\t\t\thandleClearSelectedBlock( ownerDocument.activeElement );\n\t\t\t}\n\n\t\t\townerDocument.addEventListener( 'mousedown', handleMouseDown );\n\t\t\townerWindow.addEventListener( 'blur', handleBlur );\n\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'mousedown',\n\t\t\t\t\thandleMouseDown\n\t\t\t\t);\n\t\t\t\townerWindow.removeEventListener( 'blur', handleBlur );\n\t\t\t};\n\t\t}\n\t}, [\n\t\tpopoverRef,\n\t\tsidebarControl,\n\t\thasSelectedBlock,\n\t\thasMultiSelection,\n\t\tclearSelectedBlock,\n\t] );\n}\n"],
5
- "mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,aAAa,iBAAiB;AACvC,SAAS,SAAS,wBAAwB;AAkB3B,SAAR,sBAAwC,gBAAgB,YAAa;AAC3E,QAAM,EAAE,kBAAkB,kBAAkB,IAC3C,UAAW,gBAAiB;AAC7B,QAAM,EAAE,mBAAmB,IAAI,YAAa,gBAAiB;AAE7D,YAAW,MAAM;AAChB,QAAK,WAAW,WAAW,gBAAiB;AAM3C,UAAS,2BAAT,SAAmC,SAAU;AAC5C;AAAA;AAAA,WAEG,iBAAiB,KAAK,kBAAkB;AAAA,UAE1C,WACA,cAAc,SAAU,OAAQ;AAAA,UAEhC,CAAE,UAAU,SAAU,OAAQ,KAC9B,CAAE,WAAW,QAAQ,SAAU,OAAQ,KACvC,CAAE,QAAQ,QAAS,iBAAkB;AAAA,UAErC,CAAE,UAAU,SAAS;AAAA,UACpB;AACD,6BAAmB;AAAA,QACpB;AAAA,MACD,GAGS,kBAAT,SAA0B,OAAQ;AACjC,iCAA0B,MAAM,MAAO;AAAA,MACxC,GAES,aAAT,WAAsB;AACrB,iCAA0B,cAAc,aAAc;AAAA,MACvD;AA9BA,YAAM,YAAY,eAAe;AACjC,YAAM,YAAY,eAAe,UAAW,CAAE;AAC9C,YAAM,gBAAgB,UAAU;AAChC,YAAM,cAAc,cAAc;AA6BlC,oBAAc,iBAAkB,aAAa,eAAgB;AAC7D,kBAAY,iBAAkB,QAAQ,UAAW;AAEjD,aAAO,MAAM;AACZ,sBAAc;AAAA,UACb;AAAA,UACA;AAAA,QACD;AACA,oBAAY,oBAAqB,QAAQ,UAAW;AAAA,MACrD;AAAA,IACD;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
4
+ "sourcesContent": ["import { useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * We can't just use <BlockSelectionClearer> because the customizer has\n * many root nodes rather than just one in the post editor.\n * We need to listen to the focus events in all those roots, and also in\n * the preview iframe.\n * This hook will clear the selected block when focusing outside the editor,\n * with a few exceptions:\n * 1. Focusing on popovers, including `@wordpress/ui` overlays.\n * 2. Focusing on the inspector.\n * 3. Focusing on any modals/dialogs.\n * These cases are normally triggered by user interactions from the editor,\n * not by explicitly focusing outside the editor, hence no need for clearing.\n *\n * @param {Object} sidebarControl The sidebar control instance.\n * @param {Object} popoverRef The ref object of the popover node container.\n */\nexport default function useClearSelectedBlock( sidebarControl, popoverRef ) {\n\tconst { hasSelectedBlock, hasMultiSelection } =\n\t\tuseSelect( blockEditorStore );\n\tconst { clearSelectedBlock } = useDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( popoverRef.current && sidebarControl ) {\n\t\t\tconst inspector = sidebarControl.inspector;\n\t\t\tconst container = sidebarControl.container[ 0 ];\n\t\t\tconst ownerDocument = container.ownerDocument;\n\t\t\tconst ownerWindow = ownerDocument.defaultView;\n\n\t\t\tfunction handleClearSelectedBlock( element ) {\n\t\t\t\tif (\n\t\t\t\t\t// 1. Make sure there are blocks being selected.\n\t\t\t\t\t( hasSelectedBlock() || hasMultiSelection() ) &&\n\t\t\t\t\t// 2. The element should exist in the DOM (not deleted).\n\t\t\t\t\telement &&\n\t\t\t\t\townerDocument.contains( element ) &&\n\t\t\t\t\t// 3. It should also not exist in the container, the popover, nor the dialog.\n\t\t\t\t\t! container.contains( element ) &&\n\t\t\t\t\t! popoverRef.current.contains( element ) &&\n\t\t\t\t\t! element.closest( '[data-wp-compat-overlay-slot]' ) &&\n\t\t\t\t\t! element.closest( '[role=\"dialog\"]' ) &&\n\t\t\t\t\t// 4. The inspector should not be opened.\n\t\t\t\t\t! inspector.expanded()\n\t\t\t\t) {\n\t\t\t\t\tclearSelectedBlock();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Handle mouse down in the same document.\n\t\t\tfunction handleMouseDown( event ) {\n\t\t\t\thandleClearSelectedBlock( event.target );\n\t\t\t}\n\t\t\t// Handle focusing outside the current document, like to iframes.\n\t\t\tfunction handleBlur() {\n\t\t\t\thandleClearSelectedBlock( ownerDocument.activeElement );\n\t\t\t}\n\n\t\t\townerDocument.addEventListener( 'mousedown', handleMouseDown );\n\t\t\townerWindow.addEventListener( 'blur', handleBlur );\n\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'mousedown',\n\t\t\t\t\thandleMouseDown\n\t\t\t\t);\n\t\t\t\townerWindow.removeEventListener( 'blur', handleBlur );\n\t\t\t};\n\t\t}\n\t}, [\n\t\tpopoverRef,\n\t\tsidebarControl,\n\t\thasSelectedBlock,\n\t\thasMultiSelection,\n\t\tclearSelectedBlock,\n\t] );\n}\n"],
5
+ "mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,aAAa,iBAAiB;AACvC,SAAS,SAAS,wBAAwB;AAkB3B,SAAR,sBAAwC,gBAAgB,YAAa;AAC3E,QAAM,EAAE,kBAAkB,kBAAkB,IAC3C,UAAW,gBAAiB;AAC7B,QAAM,EAAE,mBAAmB,IAAI,YAAa,gBAAiB;AAE7D,YAAW,MAAM;AAChB,QAAK,WAAW,WAAW,gBAAiB;AAM3C,UAAS,2BAAT,SAAmC,SAAU;AAC5C;AAAA;AAAA,WAEG,iBAAiB,KAAK,kBAAkB;AAAA,UAE1C,WACA,cAAc,SAAU,OAAQ;AAAA,UAEhC,CAAE,UAAU,SAAU,OAAQ,KAC9B,CAAE,WAAW,QAAQ,SAAU,OAAQ,KACvC,CAAE,QAAQ,QAAS,+BAAgC,KACnD,CAAE,QAAQ,QAAS,iBAAkB;AAAA,UAErC,CAAE,UAAU,SAAS;AAAA,UACpB;AACD,6BAAmB;AAAA,QACpB;AAAA,MACD,GAGS,kBAAT,SAA0B,OAAQ;AACjC,iCAA0B,MAAM,MAAO;AAAA,MACxC,GAES,aAAT,WAAsB;AACrB,iCAA0B,cAAc,aAAc;AAAA,MACvD;AA/BA,YAAM,YAAY,eAAe;AACjC,YAAM,YAAY,eAAe,UAAW,CAAE;AAC9C,YAAM,gBAAgB,UAAU;AAChC,YAAM,cAAc,cAAc;AA8BlC,oBAAc,iBAAkB,aAAa,eAAgB;AAC7D,kBAAY,iBAAkB,QAAQ,UAAW;AAEjD,aAAO,MAAM;AACZ,sBAAc;AAAA,UACb;AAAA,UACA;AAAA,QACD;AACA,oBAAY,oBAAqB,QAAQ,UAAW;AAAA,MACrD;AAAA,IACD;AAAA,EACD,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
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,OAA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AP,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/>\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,IAAI,eAAe;AAC9C,UAAO,GAAI,KAAM,KAAM,WAAY,IAAI,WAAY;AACnD,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,UAAM,EAAE,OAAO,YAAY,IAAI,eAAe;AAE9C,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,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": "6.0.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",
@@ -17,15 +17,14 @@
17
17
  "url": "https://github.com/WordPress/gutenberg/issues"
18
18
  },
19
19
  "engines": {
20
- "node": ">=18.12.0"
20
+ "node": ">=22.13.0"
21
21
  },
22
22
  "files": [
23
23
  "src",
24
24
  "build",
25
25
  "build-module",
26
26
  "build-style",
27
- "build-types",
28
- "*.md"
27
+ "build-types"
29
28
  ],
30
29
  "main": "build/index.cjs",
31
30
  "module": "build-module/index.mjs",
@@ -38,37 +37,38 @@
38
37
  },
39
38
  "wpScript": true,
40
39
  "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",
40
+ "@wordpress/a11y": "^5.0.0",
41
+ "@wordpress/admin-ui": "^3.0.0",
42
+ "@wordpress/base-styles": "^14.0.0",
43
+ "@wordpress/block-editor": "^19.0.0",
44
+ "@wordpress/block-library": "^12.0.0",
45
+ "@wordpress/blocks": "^17.0.0",
46
+ "@wordpress/components": "^43.0.0",
47
+ "@wordpress/compose": "^9.0.0",
48
+ "@wordpress/core-data": "^9.0.0",
49
+ "@wordpress/data": "^11.0.0",
50
+ "@wordpress/dom": "^5.0.0",
51
+ "@wordpress/element": "^10.0.0",
52
+ "@wordpress/hooks": "^5.0.0",
53
+ "@wordpress/i18n": "^7.0.0",
54
+ "@wordpress/icons": "^19.0.0",
55
+ "@wordpress/is-shallow-equal": "^6.0.0",
56
+ "@wordpress/keyboard-shortcuts": "^6.0.0",
57
+ "@wordpress/keycodes": "^5.0.0",
58
+ "@wordpress/media-utils": "^6.0.0",
59
+ "@wordpress/preferences": "^5.0.0",
60
+ "@wordpress/private-apis": "^3.0.0",
61
+ "@wordpress/theme": "^3.0.0",
62
+ "@wordpress/ui": "^0.25.0",
63
+ "@wordpress/widgets": "^5.0.0",
64
64
  "clsx": "^2.1.1",
65
65
  "fast-deep-equal": "^3.1.3"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@testing-library/dom": "^10.4.2",
69
69
  "@testing-library/react": "^16.3.3",
70
- "@testing-library/user-event": "^14.6.1",
71
- "vitest": "^5.0.0"
70
+ "@testing-library/user-event": "^14.6.8",
71
+ "vitest": "^5.0.3"
72
72
  },
73
73
  "peerDependencies": {
74
74
  "react": "^18 || ^19",
@@ -77,5 +77,5 @@
77
77
  "publishConfig": {
78
78
  "access": "public"
79
79
  },
80
- "gitHead": "56d8058eda6e30c4cc8bfc37818fa6ed972f7dc2"
80
+ "gitHead": "8d30f92cbbde3ddf781c8799443c649befbbcb88"
81
81
  }
@@ -8,6 +8,7 @@ import {
8
8
  } from '@wordpress/element';
9
9
  import { SlotFillProvider, Popover } from '@wordpress/components';
10
10
  import { ThemeProvider } from '@wordpress/theme';
11
+ import { useEnableWpCompatOverlaySlot } from '@wordpress/ui';
11
12
  import ErrorBoundary from '../error-boundary';
12
13
  import SidebarBlockEditor from '../sidebar-block-editor';
13
14
  import FocusControl from '../focus-control';
@@ -26,6 +27,8 @@ export default function CustomizeWidgets( {
26
27
  const popoverRef = useRef();
27
28
  const adminPrimary = useMemo( () => getAdminThemeColors().primary, [] );
28
29
 
30
+ // `useClearSelectedBlock` relies on the slot marker to spot overlays.
31
+ useEnableWpCompatOverlaySlot();
29
32
  useClearSelectedBlock( activeSidebarControl, popoverRef );
30
33
 
31
34
  useEffect( () => {
@@ -9,7 +9,7 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
9
9
  * the preview iframe.
10
10
  * This hook will clear the selected block when focusing outside the editor,
11
11
  * with a few exceptions:
12
- * 1. Focusing on popovers.
12
+ * 1. Focusing on popovers, including `@wordpress/ui` overlays.
13
13
  * 2. Focusing on the inspector.
14
14
  * 3. Focusing on any modals/dialogs.
15
15
  * These cases are normally triggered by user interactions from the editor,
@@ -40,6 +40,7 @@ export default function useClearSelectedBlock( sidebarControl, popoverRef ) {
40
40
  // 3. It should also not exist in the container, the popover, nor the dialog.
41
41
  ! container.contains( element ) &&
42
42
  ! popoverRef.current.contains( element ) &&
43
+ ! element.closest( '[data-wp-compat-overlay-slot]' ) &&
43
44
  ! element.closest( '[role="dialog"]' ) &&
44
45
  // 4. The inspector should not be opened.
45
46
  ! inspector.expanded()
@@ -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
 
package/CHANGELOG.md DELETED
@@ -1,283 +0,0 @@
1
- <!-- Learn how to maintain this file at https://github.com/WordPress/gutenberg/tree/HEAD/packages#maintaining-changelogs. -->
2
-
3
- ## Unreleased
4
-
5
- ## 5.56.0 (2026-09-23)
6
-
7
- ### Bug Fixes
8
-
9
- - Open the Welcome Guide from a plain menu item instead of a preference toggle, so the Options menu no longer announces "Preference activated - Welcome Guide" ([#82395](https://github.com/WordPress/gutenberg/pull/82395)).
10
- - Use `aria-disabled` for the Undo and Redo buttons of the document tools so they stay focusable when there is nothing to undo or redo, and make the focus style of all the document tools buttons visible ([#82412](https://github.com/WordPress/gutenberg/pull/82412)).
11
-
12
- ## 5.55.0 (2026-09-10)
13
-
14
- ### Enhancements
15
-
16
- - Error boundary: Surface debugging details ([#82099](https://github.com/WordPress/gutenberg/pull/82099)).
17
-
18
- ### Internal
19
-
20
- - Stop passing the unused `editorTool` block editor setting; the selector that read it was removed with the Write/Design tool in [#72193](https://github.com/WordPress/gutenberg/pull/72193) ([#82677](https://github.com/WordPress/gutenberg/pull/82677)).
21
- - Remove unused dependency `@wordpress/interface` ([#82103](https://github.com/WordPress/gutenberg/pull/82103)).
22
- - Use the `.jsx` extension for JavaScript source files that contain JSX ([#80990](https://github.com/WordPress/gutenberg/pull/80990)).
23
-
24
- ## 5.54.0 (2026-08-26)
25
-
26
- ## 5.53.0 (2026-08-12)
27
-
28
- ### Enhancements
29
-
30
- - Wrap the Customizer widgets editor in `ThemeProvider`, seeded with the active admin color scheme primary color ([#81174](https://github.com/WordPress/gutenberg/pull/81174)).
31
-
32
- ## 5.52.0 (2026-07-29)
33
-
34
- ## 5.51.0 (2026-07-14)
35
-
36
- ### Enhancements
37
-
38
- - Widen React peer dependency ranges to `^18 || ^19` to support both React 18 and React 19 environments ([#80024](https://github.com/WordPress/gutenberg/pull/80024)).
39
-
40
- ## 5.50.0 (2026-07-01)
41
-
42
- ## 5.49.0 (2026-06-24)
43
-
44
- ## 5.48.1 (2026-06-16)
45
-
46
- ## 5.48.0 (2026-06-10)
47
-
48
- ## 5.47.0 (2026-05-27)
49
-
50
- ## 5.46.0 (2026-05-14)
51
-
52
- ## 5.45.0 (2026-04-29)
53
-
54
- ## 5.44.0 (2026-04-15)
55
-
56
- ## 5.43.0 (2026-04-01)
57
-
58
- ## 5.42.0 (2026-03-18)
59
-
60
- ## 5.41.0 (2026-03-04)
61
-
62
- ## 5.40.0 (2026-02-18)
63
-
64
- ## 5.39.0 (2026-01-29)
65
-
66
- ## 5.38.0 (2026-01-16)
67
-
68
- ## 5.36.0 (2025-11-26)
69
-
70
- ## 5.35.0 (2025-11-12)
71
-
72
- ## 5.34.0 (2025-10-29)
73
-
74
- ## 5.33.0 (2025-10-17)
75
-
76
- ## 5.32.0 (2025-10-01)
77
-
78
- ## 5.31.0 (2025-09-17)
79
-
80
- ## 5.30.0 (2025-09-03)
81
-
82
- ## 5.29.0 (2025-08-20)
83
-
84
- ## 5.28.0 (2025-08-07)
85
-
86
- ## 5.27.0 (2025-07-23)
87
-
88
- ## 5.26.0 (2025-06-25)
89
-
90
- ## 5.25.0 (2025-06-04)
91
-
92
- ## 5.24.0 (2025-05-22)
93
-
94
- ## 5.23.0 (2025-05-07)
95
-
96
- ## 5.22.0 (2025-04-11)
97
-
98
- ## 5.21.0 (2025-03-27)
99
-
100
- ## 5.20.0 (2025-03-13)
101
-
102
- ## 5.19.0 (2025-02-28)
103
-
104
- ## 5.18.0 (2025-02-12)
105
-
106
- ## 5.17.0 (2025-01-29)
107
-
108
- ## 5.16.0 (2025-01-15)
109
-
110
- ## 5.15.0 (2025-01-02)
111
-
112
- ## 5.14.0 (2024-12-11)
113
-
114
- ## 5.13.0 (2024-11-27)
115
-
116
- ## 5.12.0 (2024-11-16)
117
-
118
- ## 5.11.0 (2024-10-30)
119
-
120
- ## 5.10.0 (2024-10-16)
121
-
122
- ## 5.9.0 (2024-10-03)
123
-
124
- ## 5.8.0 (2024-09-19)
125
-
126
- ## 5.7.0 (2024-09-05)
127
-
128
- ## 5.6.0 (2024-08-21)
129
-
130
- ## 5.5.0 (2024-08-07)
131
-
132
- ## 5.4.0 (2024-07-24)
133
-
134
- ## 5.3.0 (2024-07-10)
135
-
136
- ## 5.2.0 (2024-06-26)
137
-
138
- ## 5.1.0 (2024-06-15)
139
-
140
- ## 5.0.0 (2024-05-31)
141
-
142
- ### Breaking Changes
143
-
144
- - Variables like `process.env.IS_GUTENBERG_PLUGIN` have been replaced by `globalThis.IS_GUTENBERG_PLUGIN`. Build systems using `process.env` should be updated ([#61486](https://github.com/WordPress/gutenberg/pull/61486)).
145
- - Increase the minimum required Node.js version to v18.12.0 matching long-term support releases ([#31270](https://github.com/WordPress/gutenberg/pull/61930)). Learn more about [Node.js releases](https://nodejs.org/en/about/previous-releases).
146
-
147
- ## 4.35.0 (2024-05-16)
148
-
149
- ## 4.34.0 (2024-05-02)
150
-
151
- ## 4.33.0 (2024-04-19)
152
-
153
- ## 4.32.0 (2024-04-03)
154
-
155
- ## 4.31.0 (2024-03-21)
156
-
157
- ## 4.30.0 (2024-03-06)
158
-
159
- ## 4.29.0 (2024-02-21)
160
-
161
- ## 4.28.0 (2024-02-09)
162
-
163
- ## 4.27.0 (2024-01-24)
164
-
165
- ## 4.26.0 (2024-01-10)
166
-
167
- ## 4.25.0 (2023-12-13)
168
-
169
- ## 4.24.0 (2023-11-29)
170
-
171
- ## 4.23.0 (2023-11-16)
172
-
173
- ## 4.22.0 (2023-11-02)
174
-
175
- ## 4.21.0 (2023-10-18)
176
-
177
- ## 4.20.0 (2023-10-05)
178
-
179
- ## 4.19.0 (2023-09-20)
180
-
181
- ## 4.18.0 (2023-08-31)
182
-
183
- ## 4.17.0 (2023-08-16)
184
-
185
- ## 4.16.0 (2023-08-10)
186
-
187
- ## 4.15.0 (2023-07-20)
188
-
189
- ## 4.14.0 (2023-07-05)
190
-
191
- ## 4.13.0 (2023-06-23)
192
-
193
- ## 4.12.0 (2023-06-07)
194
-
195
- ## 4.11.0 (2023-05-24)
196
-
197
- ## 4.10.0 (2023-05-10)
198
-
199
- ## 4.9.0 (2023-04-26)
200
-
201
- ## 4.8.0 (2023-04-12)
202
-
203
- ## 4.7.0 (2023-03-29)
204
-
205
- ## 4.6.0 (2023-03-15)
206
-
207
- ## 4.5.0 (2023-03-01)
208
-
209
- ## 4.4.0 (2023-02-15)
210
-
211
- ## 4.3.0 (2023-02-01)
212
-
213
- ## 4.2.0 (2023-01-11)
214
-
215
- ## 4.1.0 (2023-01-02)
216
-
217
- ## 4.0.0 (2022-12-14)
218
-
219
- ### Breaking Changes
220
-
221
- - Updated dependencies to require React 18 ([45235](https://github.com/WordPress/gutenberg/pull/45235))
222
-
223
- ## 3.19.0 (2022-11-16)
224
-
225
- ## 3.18.0 (2022-11-02)
226
-
227
- ## 3.17.0 (2022-10-19)
228
-
229
- ## 3.16.0 (2022-10-05)
230
-
231
- ## 3.15.0 (2022-09-21)
232
-
233
- ## 3.14.0 (2022-09-13)
234
-
235
- ## 3.13.0 (2022-08-24)
236
-
237
- ## 3.12.0 (2022-08-10)
238
-
239
- ## 3.11.0 (2022-07-27)
240
-
241
- ## 3.10.0 (2022-07-13)
242
-
243
- ## 3.9.0 (2022-06-29)
244
-
245
- ## 3.8.0 (2022-06-15)
246
-
247
- ## 3.7.0 (2022-06-01)
248
-
249
- ## 3.6.0 (2022-05-18)
250
-
251
- ## 3.5.0 (2022-05-04)
252
-
253
- ## 3.4.0 (2022-04-21)
254
-
255
- ## 3.3.0 (2022-04-08)
256
-
257
- ## 3.2.0 (2022-03-23)
258
-
259
- ## 3.1.0 (2022-03-11)
260
-
261
- ## 3.0.0 (2022-02-10)
262
-
263
- ### Breaking Changes
264
-
265
- - The `GUTENBERG_PHASE` environment variable has been renamed to `IS_GUTENBERG_PLUGIN` and is now a boolean ([#38202](https://github.com/WordPress/gutenberg/pull/38202)).
266
-
267
- ### Bug Fixes
268
-
269
- - Removed unused `@wordpress/a11y` dependency ([#38388](https://github.com/WordPress/gutenberg/pull/38388)).
270
-
271
- ## 2.1.0 (2022-01-27)
272
-
273
- ## 2.0.0 (2021-07-29)
274
-
275
- ### Breaking Changes
276
-
277
- - Upgraded React components to work with v17.0 ([#29118](https://github.com/WordPress/gutenberg/pull/29118)). There are no new features in React v17.0 as explained in the [blog post](https://reactjs.org/blog/2020/10/20/react-v17.html).
278
-
279
- ## 1.1.0 (2021-07-21)
280
-
281
- ## 1.0.0 (2021-05-24)
282
-
283
- - Initial release of the package.