@wordpress/components 30.6.4 → 30.6.5

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
@@ -7,6 +7,8 @@
7
7
  - `Badge`: Add max-width for text truncation ([#72653](https://github.com/WordPress/gutenberg/pull/72653)).
8
8
  - `Button`: Revert disabled primary button state to its previous one ([#73037](https://github.com/WordPress/gutenberg/pull/73037)).
9
9
  - `NumberControl`: Fix crash when min prop is string and step prop contains decimal ([#73107](https://github.com/WordPress/gutenberg/pull/73107)).
10
+ - `Popover`: Fix `onDialogClose` logic to only close the popover if the blur event targets the specific popover instance ([#72376](https://github.com/WordPress/gutenberg/pull/72376)).
11
+ - `Popover`: Fix bug where clicking outside nested popovers only closed the inner one. ([#74340](https://github.com/WordPress/gutenberg/pull/74340))
10
12
 
11
13
  ## 30.6.0 (2025-10-17)
12
14
 
@@ -184,8 +184,20 @@ const UnforwardedPopover = (props, forwardedRef) => {
184
184
  let onDialogClose;
185
185
  if (onClose || onFocusOutside) {
186
186
  onDialogClose = (type, event) => {
187
- if (type === "focus-outside" && onFocusOutside) {
188
- onFocusOutside(event);
187
+ if (type === "focus-outside") {
188
+ const blurTarget = event?.target;
189
+ const referenceElement = refs.reference.current;
190
+ const floatingElement = refs.floating.current;
191
+ const isBlurFromThisPopover = referenceElement && "contains" in referenceElement && referenceElement.contains(blurTarget) || floatingElement?.contains(blurTarget);
192
+ const ownerDocument = floatingElement?.ownerDocument;
193
+ if (!isBlurFromThisPopover && !("relatedTarget" in event && event.relatedTarget) && ownerDocument?.activeElement === ownerDocument?.body) {
194
+ return;
195
+ }
196
+ if (onFocusOutside) {
197
+ onFocusOutside(event);
198
+ } else if (onClose) {
199
+ onClose();
200
+ }
189
201
  } else if (onClose) {
190
202
  onClose();
191
203
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/popover/index.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\n\nimport clsx from 'clsx';\nimport { useFloating, flip as flipMiddleware, shift as shiftMiddleware, limitShift, autoUpdate, arrow, offset as offsetMiddleware, size } from '@floating-ui/react-dom';\nimport { motion } from 'framer-motion';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useLayoutEffect, forwardRef, createContext, useContext, useMemo, useState, useCallback, createPortal } from '@wordpress/element';\nimport { useReducedMotion, useViewportMatch, useMergeRefs, __experimentalUseDialog as useDialog } from '@wordpress/compose';\nimport { close } from '@wordpress/icons';\nimport deprecated from '@wordpress/deprecated';\nimport { Path, SVG } from '@wordpress/primitives';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport ScrollLock from '../scroll-lock';\nimport { Slot, Fill, useSlot } from '../slot-fill';\nimport { computePopoverPosition, positionToPlacement, placementToMotionAnimationProps, getReferenceElement } from './utils';\nimport { contextConnect, useContextSystem } from '../context';\nimport { overlayMiddlewares } from './overlay-middlewares';\nimport { StyleProvider } from '../style-provider';\n\n/**\n * Name of slot in which popover should fill.\n *\n * @type {string}\n */\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nexport const SLOT_NAME = 'Popover';\n\n/**\n * Virtual padding to account for overflow boundaries.\n *\n * @type {number}\n */\nconst OVERFLOW_PADDING = 8;\n\n// An SVG displaying a triangle facing down, filled with a solid\n// color and bordered in such a way to create an arrow-like effect.\n// Keeping the SVG's viewbox squared simplify the arrow positioning\n// calculations.\nconst ArrowTriangle = () => /*#__PURE__*/_jsxs(SVG, {\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 100 100\",\n className: \"components-popover__triangle\",\n role: \"presentation\",\n children: [/*#__PURE__*/_jsx(Path, {\n className: \"components-popover__triangle-bg\",\n d: \"M 0 0 L 50 50 L 100 0\"\n }), /*#__PURE__*/_jsx(Path, {\n className: \"components-popover__triangle-border\",\n d: \"M 0 0 L 50 50 L 100 0\",\n vectorEffect: \"non-scaling-stroke\"\n })]\n});\nconst slotNameContext = createContext(undefined);\nslotNameContext.displayName = '__unstableSlotNameContext';\nconst fallbackContainerClassname = 'components-popover__fallback-container';\nconst getPopoverFallbackContainer = () => {\n let container = document.body.querySelector('.' + fallbackContainerClassname);\n if (!container) {\n container = document.createElement('div');\n container.className = fallbackContainerClassname;\n document.body.append(container);\n }\n return container;\n};\nconst UnforwardedPopover = (props, forwardedRef) => {\n const {\n animate = true,\n headerTitle,\n constrainTabbing,\n onClose,\n children,\n className,\n noArrow = true,\n position,\n placement: placementProp = 'bottom-start',\n offset: offsetProp = 0,\n focusOnMount = 'firstElement',\n anchor,\n expandOnMobile,\n onFocusOutside,\n __unstableSlotName = SLOT_NAME,\n flip = true,\n resize = true,\n shift = false,\n inline = false,\n variant,\n style: contentStyle,\n // Deprecated props\n __unstableForcePosition,\n anchorRef,\n anchorRect,\n getAnchorRect,\n isAlternate,\n // Rest\n ...contentProps\n } = useContextSystem(props, 'Popover');\n let computedFlipProp = flip;\n let computedResizeProp = resize;\n if (__unstableForcePosition !== undefined) {\n deprecated('`__unstableForcePosition` prop in wp.components.Popover', {\n since: '6.1',\n version: '6.3',\n alternative: '`flip={ false }` and `resize={ false }`'\n });\n\n // Back-compat, set the `flip` and `resize` props\n // to `false` to replicate `__unstableForcePosition`.\n computedFlipProp = !__unstableForcePosition;\n computedResizeProp = !__unstableForcePosition;\n }\n if (anchorRef !== undefined) {\n deprecated('`anchorRef` prop in wp.components.Popover', {\n since: '6.1',\n alternative: '`anchor` prop'\n });\n }\n if (anchorRect !== undefined) {\n deprecated('`anchorRect` prop in wp.components.Popover', {\n since: '6.1',\n alternative: '`anchor` prop'\n });\n }\n if (getAnchorRect !== undefined) {\n deprecated('`getAnchorRect` prop in wp.components.Popover', {\n since: '6.1',\n alternative: '`anchor` prop'\n });\n }\n const computedVariant = isAlternate ? 'toolbar' : variant;\n if (isAlternate !== undefined) {\n deprecated('`isAlternate` prop in wp.components.Popover', {\n since: '6.2',\n alternative: \"`variant` prop with the `'toolbar'` value\"\n });\n }\n const arrowRef = useRef(null);\n const [fallbackReferenceElement, setFallbackReferenceElement] = useState(null);\n const anchorRefFallback = useCallback(node => {\n setFallbackReferenceElement(node);\n }, []);\n const isMobileViewport = useViewportMatch('medium', '<');\n const isExpanded = expandOnMobile && isMobileViewport;\n const hasArrow = !isExpanded && !noArrow;\n const normalizedPlacementFromProps = position ? positionToPlacement(position) : placementProp;\n const middleware = [...(placementProp === 'overlay' ? overlayMiddlewares() : []), offsetMiddleware(offsetProp), computedFlipProp && flipMiddleware(), computedResizeProp && size({\n padding: OVERFLOW_PADDING,\n apply(sizeProps) {\n var _refs$floating$curren;\n const {\n firstElementChild\n } = (_refs$floating$curren = refs.floating.current) !== null && _refs$floating$curren !== void 0 ? _refs$floating$curren : {};\n\n // Only HTMLElement instances have the `style` property.\n if (!(firstElementChild instanceof HTMLElement)) {\n return;\n }\n\n // Reduce the height of the popover to the available space.\n Object.assign(firstElementChild.style, {\n maxHeight: `${Math.max(0, sizeProps.availableHeight)}px`,\n overflow: 'auto'\n });\n }\n }), shift && shiftMiddleware({\n crossAxis: true,\n limiter: limitShift(),\n padding: 1 // Necessary to avoid flickering at the edge of the viewport.\n }), arrow({\n element: arrowRef\n })];\n const slotName = useContext(slotNameContext) || __unstableSlotName;\n const slot = useSlot(slotName);\n let onDialogClose;\n if (onClose || onFocusOutside) {\n onDialogClose = (type, event) => {\n // Ideally the popover should have just a single onClose prop and\n // not three props that potentially do the same thing.\n if (type === 'focus-outside' && onFocusOutside) {\n onFocusOutside(event);\n } else if (onClose) {\n onClose();\n }\n };\n }\n const [dialogRef, dialogProps] = useDialog({\n constrainTabbing,\n focusOnMount,\n __unstableOnClose: onDialogClose,\n // @ts-expect-error The __unstableOnClose property needs to be deprecated first (see https://github.com/WordPress/gutenberg/pull/27675)\n onClose: onDialogClose\n });\n const {\n // Positioning coordinates\n x,\n y,\n // Object with \"regular\" refs to both \"reference\" and \"floating\"\n refs,\n // Type of CSS position property to use (absolute or fixed)\n strategy,\n update,\n placement: computedPlacement,\n middlewareData: {\n arrow: arrowData\n }\n } = useFloating({\n placement: normalizedPlacementFromProps === 'overlay' ? undefined : normalizedPlacementFromProps,\n middleware,\n whileElementsMounted: (referenceParam, floatingParam, updateParam) => autoUpdate(referenceParam, floatingParam, updateParam, {\n layoutShift: false,\n animationFrame: true\n })\n });\n const arrowCallbackRef = useCallback(node => {\n arrowRef.current = node;\n update();\n }, [update]);\n\n // When any of the possible anchor \"sources\" change,\n // recompute the reference element (real or virtual) and its owner document.\n\n const anchorRefTop = anchorRef?.top;\n const anchorRefBottom = anchorRef?.bottom;\n const anchorRefStartContainer = anchorRef?.startContainer;\n const anchorRefCurrent = anchorRef?.current;\n useLayoutEffect(() => {\n const resultingReferenceElement = getReferenceElement({\n anchor,\n anchorRef,\n anchorRect,\n getAnchorRect,\n fallbackReferenceElement\n });\n refs.setReference(resultingReferenceElement);\n }, [anchor, anchorRef, anchorRefTop, anchorRefBottom, anchorRefStartContainer, anchorRefCurrent, anchorRect, getAnchorRect, fallbackReferenceElement, refs]);\n const mergedFloatingRef = useMergeRefs([refs.setFloating, dialogRef, forwardedRef]);\n const style = isExpanded ? undefined : {\n position: strategy,\n top: 0,\n left: 0,\n // `x` and `y` are framer-motion specific props and are shorthands\n // for `translateX` and `translateY`. Currently it is not possible\n // to use `translateX` and `translateY` because those values would\n // be overridden by the return value of the\n // `placementToMotionAnimationProps` function.\n x: computePopoverPosition(x),\n y: computePopoverPosition(y)\n };\n const shouldReduceMotion = useReducedMotion();\n const shouldAnimate = animate && !isExpanded && !shouldReduceMotion;\n const [animationFinished, setAnimationFinished] = useState(false);\n const {\n style: motionInlineStyles,\n ...otherMotionProps\n } = useMemo(() => placementToMotionAnimationProps(computedPlacement), [computedPlacement]);\n const animationProps = shouldAnimate ? {\n style: {\n ...contentStyle,\n ...motionInlineStyles,\n ...style\n },\n onAnimationComplete: () => setAnimationFinished(true),\n ...otherMotionProps\n } : {\n animate: false,\n style: {\n ...contentStyle,\n ...style\n }\n };\n\n // When Floating UI has finished positioning and Framer Motion has finished animating\n // the popover, add the `is-positioned` class to signal that all transitions have finished.\n const isPositioned = (!shouldAnimate || animationFinished) && x !== null && y !== null;\n let content = /*#__PURE__*/_jsxs(motion.div, {\n className: clsx(className, {\n 'is-expanded': isExpanded,\n 'is-positioned': isPositioned,\n // Use the 'alternate' classname for 'toolbar' variant for back compat.\n [`is-${computedVariant === 'toolbar' ? 'alternate' : computedVariant}`]: computedVariant\n }),\n ...animationProps,\n ...contentProps,\n ref: mergedFloatingRef,\n ...dialogProps,\n tabIndex: -1,\n children: [isExpanded && /*#__PURE__*/_jsx(ScrollLock, {}), isExpanded && /*#__PURE__*/_jsxs(\"div\", {\n className: \"components-popover__header\",\n children: [/*#__PURE__*/_jsx(\"span\", {\n className: \"components-popover__header-title\",\n children: headerTitle\n }), /*#__PURE__*/_jsx(Button, {\n className: \"components-popover__close\",\n size: \"small\",\n icon: close,\n onClick: onClose,\n label: __('Close')\n })]\n }), /*#__PURE__*/_jsx(\"div\", {\n className: \"components-popover__content\",\n children: children\n }), hasArrow && /*#__PURE__*/_jsx(\"div\", {\n ref: arrowCallbackRef,\n className: ['components-popover__arrow', `is-${computedPlacement.split('-')[0]}`].join(' '),\n style: {\n left: typeof arrowData?.x !== 'undefined' && Number.isFinite(arrowData.x) ? `${arrowData.x}px` : '',\n top: typeof arrowData?.y !== 'undefined' && Number.isFinite(arrowData.y) ? `${arrowData.y}px` : ''\n },\n children: /*#__PURE__*/_jsx(ArrowTriangle, {})\n })]\n });\n const shouldRenderWithinSlot = slot.ref && !inline;\n const hasAnchor = anchorRef || anchorRect || anchor;\n if (shouldRenderWithinSlot) {\n content = /*#__PURE__*/_jsx(Fill, {\n name: slotName,\n children: content\n });\n } else if (!inline) {\n content = createPortal(/*#__PURE__*/_jsx(StyleProvider, {\n document: document,\n children: content\n }), getPopoverFallbackContainer());\n }\n if (hasAnchor) {\n return content;\n }\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsx(\"span\", {\n ref: anchorRefFallback\n }), content]\n });\n};\n\n// Export the PopoverSlot individually to allow typescript to pick the types up.\nexport const PopoverSlot = forwardRef(({\n name = SLOT_NAME\n}, ref) => {\n return /*#__PURE__*/_jsx(Slot, {\n bubblesVirtually: true,\n name: name,\n className: \"popover-slot\",\n ref: ref\n });\n});\n\n/**\n * `Popover` renders its content in a floating modal. If no explicit anchor is passed via props, it anchors to its parent element by default.\n *\n * ```jsx\n * import { Button, Popover } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyPopover = () => {\n * \tconst [ isVisible, setIsVisible ] = useState( false );\n * \tconst toggleVisible = () => {\n * \t\tsetIsVisible( ( state ) => ! state );\n * \t};\n *\n * \treturn (\n * \t\t<Button variant=\"secondary\" onClick={ toggleVisible }>\n * \t\t\tToggle Popover!\n * \t\t\t{ isVisible && <Popover>Popover is toggled!</Popover> }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n */\nexport const Popover = Object.assign(contextConnect(UnforwardedPopover, 'Popover'), {\n /**\n * Renders a slot that is used internally by Popover for rendering content.\n */\n Slot: Object.assign(PopoverSlot, {\n displayName: 'Popover.Slot'\n }),\n /**\n * Provides a context to manage popover slot names.\n *\n * This is marked as unstable and should not be used directly.\n */\n __unstableSlotNameProvider: Object.assign(slotNameContext.Provider, {\n displayName: 'Popover.__unstableSlotNameProvider'\n })\n});\nexport default Popover;"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAiB;AACjB,uBAA+I;AAC/I,2BAAuB;AAKvB,qBAA6H;AAC7H,qBAAuG;AACvG,mBAAsB;AACtB,wBAAuB;AACvB,wBAA0B;AAC1B,kBAAmB;AAKnB,oBAAmB;AACnB,yBAAuB;AACvB,uBAAoC;AACpC,mBAAkH;AAClH,qBAAiD;A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AAe,CAAC,CAAC;AAAA,IAC/C,CAAC,CAAC;AAAA,EACJ,CAAC;AACD,QAAM,yBAAyB,KAAK,OAAO,CAAC;AAC5C,QAAM,YAAY,aAAa,cAAc;AAC7C,MAAI,wBAAwB;AAC1B,cAAuB,uCAAAA,KAAK,uBAAM;AAAA,MAChC,MAAM;AAAA,MACN,UAAU;AAAA,IACZ,CAAC;AAAA,EACH,WAAW,CAAC,QAAQ;AAClB,kBAAU,6BAA0B,uCAAAA,KAAK,qCAAe;AAAA,MACtD;AAAA,MACA,UAAU;AAAA,IACZ,CAAC,GAAG,4BAA4B,CAAC;AAAA,EACnC;AACA,MAAI,WAAW;AACb,WAAO;AAAA,EACT;AACA,SAAoB,uCAAAD,MAAM,mBAAAU,UAAW;AAAA,IACnC,UAAU,CAAc,uCAAAT,KAAK,QAAQ;AAAA,MACnC,KAAK;AAAA,IACP,CAAC,GAAG,OAAO;AAAA,EACb,CAAC;AACH;AAGO,MAAM,kBAAc,2BAAW,CAAC;AAAA,EACrC,OAAO;AACT,GAAG,QAAQ;AACT,SAAoB,uCAAAA,KAAK,uBAAM;AAAA,IAC7B,kBAAkB;AAAA,IAClB;AAAA,IACA,WAAW;AAAA,IACX;AAAA,EACF,CAAC;AACH,CAAC;AAyBM,MAAM,UAAU,OAAO,WAAO,+BAAe,oBAAoB,SAAS,GAAG;AAAA;AAAA;AAAA;AAAA,EAIlF,MAAM,OAAO,OAAO,aAAa;AAAA,IAC/B,aAAa;AAAA,EACf,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMD,4BAA4B,OAAO,OAAO,gBAAgB,UAAU;AAAA,IAClE,aAAa;AAAA,EACf,CAAC;AACH,CAAC;AACD,IAAO,kBAAQ;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\n\nimport clsx from 'clsx';\nimport { useFloating, flip as flipMiddleware, shift as shiftMiddleware, limitShift, autoUpdate, arrow, offset as offsetMiddleware, size } from '@floating-ui/react-dom';\nimport { motion } from 'framer-motion';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useLayoutEffect, forwardRef, createContext, useContext, useMemo, useState, useCallback, createPortal } from '@wordpress/element';\nimport { useReducedMotion, useViewportMatch, useMergeRefs, __experimentalUseDialog as useDialog } from '@wordpress/compose';\nimport { close } from '@wordpress/icons';\nimport deprecated from '@wordpress/deprecated';\nimport { Path, SVG } from '@wordpress/primitives';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport ScrollLock from '../scroll-lock';\nimport { Slot, Fill, useSlot } from '../slot-fill';\nimport { computePopoverPosition, positionToPlacement, placementToMotionAnimationProps, getReferenceElement } from './utils';\nimport { contextConnect, useContextSystem } from '../context';\nimport { overlayMiddlewares } from './overlay-middlewares';\nimport { StyleProvider } from '../style-provider';\n\n/**\n * Name of slot in which popover should fill.\n *\n * @type {string}\n */\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nexport const SLOT_NAME = 'Popover';\n\n/**\n * Virtual padding to account for overflow boundaries.\n *\n * @type {number}\n */\nconst OVERFLOW_PADDING = 8;\n\n// An SVG displaying a triangle facing down, filled with a solid\n// color and bordered in such a way to create an arrow-like effect.\n// Keeping the SVG's viewbox squared simplify the arrow positioning\n// calculations.\nconst ArrowTriangle = () => /*#__PURE__*/_jsxs(SVG, {\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 100 100\",\n className: \"components-popover__triangle\",\n role: \"presentation\",\n children: [/*#__PURE__*/_jsx(Path, {\n className: \"components-popover__triangle-bg\",\n d: \"M 0 0 L 50 50 L 100 0\"\n }), /*#__PURE__*/_jsx(Path, {\n className: \"components-popover__triangle-border\",\n d: \"M 0 0 L 50 50 L 100 0\",\n vectorEffect: \"non-scaling-stroke\"\n })]\n});\nconst slotNameContext = createContext(undefined);\nslotNameContext.displayName = '__unstableSlotNameContext';\nconst fallbackContainerClassname = 'components-popover__fallback-container';\nconst getPopoverFallbackContainer = () => {\n let container = document.body.querySelector('.' + fallbackContainerClassname);\n if (!container) {\n container = document.createElement('div');\n container.className = fallbackContainerClassname;\n document.body.append(container);\n }\n return container;\n};\nconst UnforwardedPopover = (props, forwardedRef) => {\n const {\n animate = true,\n headerTitle,\n constrainTabbing,\n onClose,\n children,\n className,\n noArrow = true,\n position,\n placement: placementProp = 'bottom-start',\n offset: offsetProp = 0,\n focusOnMount = 'firstElement',\n anchor,\n expandOnMobile,\n onFocusOutside,\n __unstableSlotName = SLOT_NAME,\n flip = true,\n resize = true,\n shift = false,\n inline = false,\n variant,\n style: contentStyle,\n // Deprecated props\n __unstableForcePosition,\n anchorRef,\n anchorRect,\n getAnchorRect,\n isAlternate,\n // Rest\n ...contentProps\n } = useContextSystem(props, 'Popover');\n let computedFlipProp = flip;\n let computedResizeProp = resize;\n if (__unstableForcePosition !== undefined) {\n deprecated('`__unstableForcePosition` prop in wp.components.Popover', {\n since: '6.1',\n version: '6.3',\n alternative: '`flip={ false }` and `resize={ false }`'\n });\n\n // Back-compat, set the `flip` and `resize` props\n // to `false` to replicate `__unstableForcePosition`.\n computedFlipProp = !__unstableForcePosition;\n computedResizeProp = !__unstableForcePosition;\n }\n if (anchorRef !== undefined) {\n deprecated('`anchorRef` prop in wp.components.Popover', {\n since: '6.1',\n alternative: '`anchor` prop'\n });\n }\n if (anchorRect !== undefined) {\n deprecated('`anchorRect` prop in wp.components.Popover', {\n since: '6.1',\n alternative: '`anchor` prop'\n });\n }\n if (getAnchorRect !== undefined) {\n deprecated('`getAnchorRect` prop in wp.components.Popover', {\n since: '6.1',\n alternative: '`anchor` prop'\n });\n }\n const computedVariant = isAlternate ? 'toolbar' : variant;\n if (isAlternate !== undefined) {\n deprecated('`isAlternate` prop in wp.components.Popover', {\n since: '6.2',\n alternative: \"`variant` prop with the `'toolbar'` value\"\n });\n }\n const arrowRef = useRef(null);\n const [fallbackReferenceElement, setFallbackReferenceElement] = useState(null);\n const anchorRefFallback = useCallback(node => {\n setFallbackReferenceElement(node);\n }, []);\n const isMobileViewport = useViewportMatch('medium', '<');\n const isExpanded = expandOnMobile && isMobileViewport;\n const hasArrow = !isExpanded && !noArrow;\n const normalizedPlacementFromProps = position ? positionToPlacement(position) : placementProp;\n const middleware = [...(placementProp === 'overlay' ? overlayMiddlewares() : []), offsetMiddleware(offsetProp), computedFlipProp && flipMiddleware(), computedResizeProp && size({\n padding: OVERFLOW_PADDING,\n apply(sizeProps) {\n var _refs$floating$curren;\n const {\n firstElementChild\n } = (_refs$floating$curren = refs.floating.current) !== null && _refs$floating$curren !== void 0 ? _refs$floating$curren : {};\n\n // Only HTMLElement instances have the `style` property.\n if (!(firstElementChild instanceof HTMLElement)) {\n return;\n }\n\n // Reduce the height of the popover to the available space.\n Object.assign(firstElementChild.style, {\n maxHeight: `${Math.max(0, sizeProps.availableHeight)}px`,\n overflow: 'auto'\n });\n }\n }), shift && shiftMiddleware({\n crossAxis: true,\n limiter: limitShift(),\n padding: 1 // Necessary to avoid flickering at the edge of the viewport.\n }), arrow({\n element: arrowRef\n })];\n const slotName = useContext(slotNameContext) || __unstableSlotName;\n const slot = useSlot(slotName);\n let onDialogClose;\n if (onClose || onFocusOutside) {\n onDialogClose = (type, event) => {\n // Ideally the popover should have just a single onClose prop and\n // not three props that potentially do the same thing.\n if (type === 'focus-outside') {\n // Check if this blur event is actually relevant to this popover\n const blurTarget = event?.target;\n const referenceElement = refs.reference.current;\n const floatingElement = refs.floating.current;\n\n // Check if blur is from this popover's reference element or its floating content\n const isBlurFromThisPopover = referenceElement && 'contains' in referenceElement && referenceElement.contains(blurTarget) || floatingElement?.contains(blurTarget);\n // Ignore blur events that don't originate from this popover when there's no\n // relatedTarget (next focus target) and focus moves to document.body.\n // This prevents incorrectly closing the popover when clicking on elements\n // that don't accept focus (like clicking outside to empty space).\n const ownerDocument = floatingElement?.ownerDocument;\n if (!isBlurFromThisPopover && !('relatedTarget' in event && event.relatedTarget) && ownerDocument?.activeElement === ownerDocument?.body) {\n return;\n }\n // Call onFocusOutside if defined or call onClose.\n if (onFocusOutside) {\n onFocusOutside(event);\n } else if (onClose) {\n onClose();\n }\n } else if (onClose) {\n // onClose should be called for other event types if it exists.\n onClose();\n }\n };\n }\n const [dialogRef, dialogProps] = useDialog({\n constrainTabbing,\n focusOnMount,\n __unstableOnClose: onDialogClose,\n // @ts-expect-error The __unstableOnClose property needs to be deprecated first (see https://github.com/WordPress/gutenberg/pull/27675)\n onClose: onDialogClose\n });\n const {\n // Positioning coordinates\n x,\n y,\n // Object with \"regular\" refs to both \"reference\" and \"floating\"\n refs,\n // Type of CSS position property to use (absolute or fixed)\n strategy,\n update,\n placement: computedPlacement,\n middlewareData: {\n arrow: arrowData\n }\n } = useFloating({\n placement: normalizedPlacementFromProps === 'overlay' ? undefined : normalizedPlacementFromProps,\n middleware,\n whileElementsMounted: (referenceParam, floatingParam, updateParam) => autoUpdate(referenceParam, floatingParam, updateParam, {\n layoutShift: false,\n animationFrame: true\n })\n });\n const arrowCallbackRef = useCallback(node => {\n arrowRef.current = node;\n update();\n }, [update]);\n\n // When any of the possible anchor \"sources\" change,\n // recompute the reference element (real or virtual) and its owner document.\n\n const anchorRefTop = anchorRef?.top;\n const anchorRefBottom = anchorRef?.bottom;\n const anchorRefStartContainer = anchorRef?.startContainer;\n const anchorRefCurrent = anchorRef?.current;\n useLayoutEffect(() => {\n const resultingReferenceElement = getReferenceElement({\n anchor,\n anchorRef,\n anchorRect,\n getAnchorRect,\n fallbackReferenceElement\n });\n refs.setReference(resultingReferenceElement);\n }, [anchor, anchorRef, anchorRefTop, anchorRefBottom, anchorRefStartContainer, anchorRefCurrent, anchorRect, getAnchorRect, fallbackReferenceElement, refs]);\n const mergedFloatingRef = useMergeRefs([refs.setFloating, dialogRef, forwardedRef]);\n const style = isExpanded ? undefined : {\n position: strategy,\n top: 0,\n left: 0,\n // `x` and `y` are framer-motion specific props and are shorthands\n // for `translateX` and `translateY`. Currently it is not possible\n // to use `translateX` and `translateY` because those values would\n // be overridden by the return value of the\n // `placementToMotionAnimationProps` function.\n x: computePopoverPosition(x),\n y: computePopoverPosition(y)\n };\n const shouldReduceMotion = useReducedMotion();\n const shouldAnimate = animate && !isExpanded && !shouldReduceMotion;\n const [animationFinished, setAnimationFinished] = useState(false);\n const {\n style: motionInlineStyles,\n ...otherMotionProps\n } = useMemo(() => placementToMotionAnimationProps(computedPlacement), [computedPlacement]);\n const animationProps = shouldAnimate ? {\n style: {\n ...contentStyle,\n ...motionInlineStyles,\n ...style\n },\n onAnimationComplete: () => setAnimationFinished(true),\n ...otherMotionProps\n } : {\n animate: false,\n style: {\n ...contentStyle,\n ...style\n }\n };\n\n // When Floating UI has finished positioning and Framer Motion has finished animating\n // the popover, add the `is-positioned` class to signal that all transitions have finished.\n const isPositioned = (!shouldAnimate || animationFinished) && x !== null && y !== null;\n let content = /*#__PURE__*/_jsxs(motion.div, {\n className: clsx(className, {\n 'is-expanded': isExpanded,\n 'is-positioned': isPositioned,\n // Use the 'alternate' classname for 'toolbar' variant for back compat.\n [`is-${computedVariant === 'toolbar' ? 'alternate' : computedVariant}`]: computedVariant\n }),\n ...animationProps,\n ...contentProps,\n ref: mergedFloatingRef,\n ...dialogProps,\n tabIndex: -1,\n children: [isExpanded && /*#__PURE__*/_jsx(ScrollLock, {}), isExpanded && /*#__PURE__*/_jsxs(\"div\", {\n className: \"components-popover__header\",\n children: [/*#__PURE__*/_jsx(\"span\", {\n className: \"components-popover__header-title\",\n children: headerTitle\n }), /*#__PURE__*/_jsx(Button, {\n className: \"components-popover__close\",\n size: \"small\",\n icon: close,\n onClick: onClose,\n label: __('Close')\n })]\n }), /*#__PURE__*/_jsx(\"div\", {\n className: \"components-popover__content\",\n children: children\n }), hasArrow && /*#__PURE__*/_jsx(\"div\", {\n ref: arrowCallbackRef,\n className: ['components-popover__arrow', `is-${computedPlacement.split('-')[0]}`].join(' '),\n style: {\n left: typeof arrowData?.x !== 'undefined' && Number.isFinite(arrowData.x) ? `${arrowData.x}px` : '',\n top: typeof arrowData?.y !== 'undefined' && Number.isFinite(arrowData.y) ? `${arrowData.y}px` : ''\n },\n children: /*#__PURE__*/_jsx(ArrowTriangle, {})\n })]\n });\n const shouldRenderWithinSlot = slot.ref && !inline;\n const hasAnchor = anchorRef || anchorRect || anchor;\n if (shouldRenderWithinSlot) {\n content = /*#__PURE__*/_jsx(Fill, {\n name: slotName,\n children: content\n });\n } else if (!inline) {\n content = createPortal(/*#__PURE__*/_jsx(StyleProvider, {\n document: document,\n children: content\n }), getPopoverFallbackContainer());\n }\n if (hasAnchor) {\n return content;\n }\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsx(\"span\", {\n ref: anchorRefFallback\n }), content]\n });\n};\n\n// Export the PopoverSlot individually to allow typescript to pick the types up.\nexport const PopoverSlot = forwardRef(({\n name = SLOT_NAME\n}, ref) => {\n return /*#__PURE__*/_jsx(Slot, {\n bubblesVirtually: true,\n name: name,\n className: \"popover-slot\",\n ref: ref\n });\n});\n\n/**\n * `Popover` renders its content in a floating modal. If no explicit anchor is passed via props, it anchors to its parent element by default.\n *\n * ```jsx\n * import { Button, Popover } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyPopover = () => {\n * \tconst [ isVisible, setIsVisible ] = useState( false );\n * \tconst toggleVisible = () => {\n * \t\tsetIsVisible( ( state ) => ! state );\n * \t};\n *\n * \treturn (\n * \t\t<Button variant=\"secondary\" onClick={ toggleVisible }>\n * \t\t\tToggle Popover!\n * \t\t\t{ isVisible && <Popover>Popover is toggled!</Popover> }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n */\nexport const Popover = Object.assign(contextConnect(UnforwardedPopover, 'Popover'), {\n /**\n * Renders a slot that is used internally by Popover for rendering content.\n */\n Slot: Object.assign(PopoverSlot, {\n displayName: 'Popover.Slot'\n }),\n /**\n * Provides a context to manage popover slot names.\n *\n * This is marked as unstable and should not be used directly.\n */\n __unstableSlotNameProvider: Object.assign(slotNameContext.Provider, {\n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,KAAK,QAAQ;AAAA,MACnC,KAAK;AAAA,IACP,CAAC,GAAG,OAAO;AAAA,EACb,CAAC;AACH;AAGO,MAAM,kBAAc,2BAAW,CAAC;AAAA,EACrC,OAAO;AACT,GAAG,QAAQ;AACT,SAAoB,uCAAAA,KAAK,uBAAM;AAAA,IAC7B,kBAAkB;AAAA,IAClB;AAAA,IACA,WAAW;AAAA,IACX;AAAA,EACF,CAAC;AACH,CAAC;AAyBM,MAAM,UAAU,OAAO,WAAO,+BAAe,oBAAoB,SAAS,GAAG;AAAA;AAAA;AAAA;AAAA,EAIlF,MAAM,OAAO,OAAO,aAAa;AAAA,IAC/B,aAAa;AAAA,EACf,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMD,4BAA4B,OAAO,OAAO,gBAAgB,UAAU;AAAA,IAClE,aAAa;AAAA,EACf,CAAC;AACH,CAAC;AACD,IAAO,kBAAQ;",
6
6
  "names": ["_jsxs", "_jsx", "deprecated", "offsetMiddleware", "flipMiddleware", "shiftMiddleware", "useDialog", "clsx", "ScrollLock", "Button", "_Fragment"]
7
7
  }
@@ -148,8 +148,20 @@ const UnforwardedPopover = (props, forwardedRef) => {
148
148
  let onDialogClose;
149
149
  if (onClose || onFocusOutside) {
150
150
  onDialogClose = (type, event) => {
151
- if (type === "focus-outside" && onFocusOutside) {
152
- onFocusOutside(event);
151
+ if (type === "focus-outside") {
152
+ const blurTarget = event?.target;
153
+ const referenceElement = refs.reference.current;
154
+ const floatingElement = refs.floating.current;
155
+ const isBlurFromThisPopover = referenceElement && "contains" in referenceElement && referenceElement.contains(blurTarget) || floatingElement?.contains(blurTarget);
156
+ const ownerDocument = floatingElement?.ownerDocument;
157
+ if (!isBlurFromThisPopover && !("relatedTarget" in event && event.relatedTarget) && ownerDocument?.activeElement === ownerDocument?.body) {
158
+ return;
159
+ }
160
+ if (onFocusOutside) {
161
+ onFocusOutside(event);
162
+ } else if (onClose) {
163
+ onClose();
164
+ }
153
165
  } else if (onClose) {
154
166
  onClose();
155
167
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/popover/index.tsx"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\n\nimport clsx from 'clsx';\nimport { useFloating, flip as flipMiddleware, shift as shiftMiddleware, limitShift, autoUpdate, arrow, offset as offsetMiddleware, size } from '@floating-ui/react-dom';\nimport { motion } from 'framer-motion';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useLayoutEffect, forwardRef, createContext, useContext, useMemo, useState, useCallback, createPortal } from '@wordpress/element';\nimport { useReducedMotion, useViewportMatch, useMergeRefs, __experimentalUseDialog as useDialog } from '@wordpress/compose';\nimport { close } from '@wordpress/icons';\nimport deprecated from '@wordpress/deprecated';\nimport { Path, SVG } from '@wordpress/primitives';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport ScrollLock from '../scroll-lock';\nimport { Slot, Fill, useSlot } from '../slot-fill';\nimport { computePopoverPosition, positionToPlacement, placementToMotionAnimationProps, getReferenceElement } from './utils';\nimport { contextConnect, useContextSystem } from '../context';\nimport { overlayMiddlewares } from './overlay-middlewares';\nimport { StyleProvider } from '../style-provider';\n\n/**\n * Name of slot in which popover should fill.\n *\n * @type {string}\n */\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nexport const SLOT_NAME = 'Popover';\n\n/**\n * Virtual padding to account for overflow boundaries.\n *\n * @type {number}\n */\nconst OVERFLOW_PADDING = 8;\n\n// An SVG displaying a triangle facing down, filled with a solid\n// color and bordered in such a way to create an arrow-like effect.\n// Keeping the SVG's viewbox squared simplify the arrow positioning\n// calculations.\nconst ArrowTriangle = () => /*#__PURE__*/_jsxs(SVG, {\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 100 100\",\n className: \"components-popover__triangle\",\n role: \"presentation\",\n children: [/*#__PURE__*/_jsx(Path, {\n className: \"components-popover__triangle-bg\",\n d: \"M 0 0 L 50 50 L 100 0\"\n }), /*#__PURE__*/_jsx(Path, {\n className: \"components-popover__triangle-border\",\n d: \"M 0 0 L 50 50 L 100 0\",\n vectorEffect: \"non-scaling-stroke\"\n })]\n});\nconst slotNameContext = createContext(undefined);\nslotNameContext.displayName = '__unstableSlotNameContext';\nconst fallbackContainerClassname = 'components-popover__fallback-container';\nconst getPopoverFallbackContainer = () => {\n let container = document.body.querySelector('.' + fallbackContainerClassname);\n if (!container) {\n container = document.createElement('div');\n container.className = fallbackContainerClassname;\n document.body.append(container);\n }\n return container;\n};\nconst UnforwardedPopover = (props, forwardedRef) => {\n const {\n animate = true,\n headerTitle,\n constrainTabbing,\n onClose,\n children,\n className,\n noArrow = true,\n position,\n placement: placementProp = 'bottom-start',\n offset: offsetProp = 0,\n focusOnMount = 'firstElement',\n anchor,\n expandOnMobile,\n onFocusOutside,\n __unstableSlotName = SLOT_NAME,\n flip = true,\n resize = true,\n shift = false,\n inline = false,\n variant,\n style: contentStyle,\n // Deprecated props\n __unstableForcePosition,\n anchorRef,\n anchorRect,\n getAnchorRect,\n isAlternate,\n // Rest\n ...contentProps\n } = useContextSystem(props, 'Popover');\n let computedFlipProp = flip;\n let computedResizeProp = resize;\n if (__unstableForcePosition !== undefined) {\n deprecated('`__unstableForcePosition` prop in wp.components.Popover', {\n since: '6.1',\n version: '6.3',\n alternative: '`flip={ false }` and `resize={ false }`'\n });\n\n // Back-compat, set the `flip` and `resize` props\n // to `false` to replicate `__unstableForcePosition`.\n computedFlipProp = !__unstableForcePosition;\n computedResizeProp = !__unstableForcePosition;\n }\n if (anchorRef !== undefined) {\n deprecated('`anchorRef` prop in wp.components.Popover', {\n since: '6.1',\n alternative: '`anchor` prop'\n });\n }\n if (anchorRect !== undefined) {\n deprecated('`anchorRect` prop in wp.components.Popover', {\n since: '6.1',\n alternative: '`anchor` prop'\n });\n }\n if (getAnchorRect !== undefined) {\n deprecated('`getAnchorRect` prop in wp.components.Popover', {\n since: '6.1',\n alternative: '`anchor` prop'\n });\n }\n const computedVariant = isAlternate ? 'toolbar' : variant;\n if (isAlternate !== undefined) {\n deprecated('`isAlternate` prop in wp.components.Popover', {\n since: '6.2',\n alternative: \"`variant` prop with the `'toolbar'` value\"\n });\n }\n const arrowRef = useRef(null);\n const [fallbackReferenceElement, setFallbackReferenceElement] = useState(null);\n const anchorRefFallback = useCallback(node => {\n setFallbackReferenceElement(node);\n }, []);\n const isMobileViewport = useViewportMatch('medium', '<');\n const isExpanded = expandOnMobile && isMobileViewport;\n const hasArrow = !isExpanded && !noArrow;\n const normalizedPlacementFromProps = position ? positionToPlacement(position) : placementProp;\n const middleware = [...(placementProp === 'overlay' ? overlayMiddlewares() : []), offsetMiddleware(offsetProp), computedFlipProp && flipMiddleware(), computedResizeProp && size({\n padding: OVERFLOW_PADDING,\n apply(sizeProps) {\n var _refs$floating$curren;\n const {\n firstElementChild\n } = (_refs$floating$curren = refs.floating.current) !== null && _refs$floating$curren !== void 0 ? _refs$floating$curren : {};\n\n // Only HTMLElement instances have the `style` property.\n if (!(firstElementChild instanceof HTMLElement)) {\n return;\n }\n\n // Reduce the height of the popover to the available space.\n Object.assign(firstElementChild.style, {\n maxHeight: `${Math.max(0, sizeProps.availableHeight)}px`,\n overflow: 'auto'\n });\n }\n }), shift && shiftMiddleware({\n crossAxis: true,\n limiter: limitShift(),\n padding: 1 // Necessary to avoid flickering at the edge of the viewport.\n }), arrow({\n element: arrowRef\n })];\n const slotName = useContext(slotNameContext) || __unstableSlotName;\n const slot = useSlot(slotName);\n let onDialogClose;\n if (onClose || onFocusOutside) {\n onDialogClose = (type, event) => {\n // Ideally the popover should have just a single onClose prop and\n // not three props that potentially do the same thing.\n if (type === 'focus-outside' && onFocusOutside) {\n onFocusOutside(event);\n } else if (onClose) {\n onClose();\n }\n };\n }\n const [dialogRef, dialogProps] = useDialog({\n constrainTabbing,\n focusOnMount,\n __unstableOnClose: onDialogClose,\n // @ts-expect-error The __unstableOnClose property needs to be deprecated first (see https://github.com/WordPress/gutenberg/pull/27675)\n onClose: onDialogClose\n });\n const {\n // Positioning coordinates\n x,\n y,\n // Object with \"regular\" refs to both \"reference\" and \"floating\"\n refs,\n // Type of CSS position property to use (absolute or fixed)\n strategy,\n update,\n placement: computedPlacement,\n middlewareData: {\n arrow: arrowData\n }\n } = useFloating({\n placement: normalizedPlacementFromProps === 'overlay' ? undefined : normalizedPlacementFromProps,\n middleware,\n whileElementsMounted: (referenceParam, floatingParam, updateParam) => autoUpdate(referenceParam, floatingParam, updateParam, {\n layoutShift: false,\n animationFrame: true\n })\n });\n const arrowCallbackRef = useCallback(node => {\n arrowRef.current = node;\n update();\n }, [update]);\n\n // When any of the possible anchor \"sources\" change,\n // recompute the reference element (real or virtual) and its owner document.\n\n const anchorRefTop = anchorRef?.top;\n const anchorRefBottom = anchorRef?.bottom;\n const anchorRefStartContainer = anchorRef?.startContainer;\n const anchorRefCurrent = anchorRef?.current;\n useLayoutEffect(() => {\n const resultingReferenceElement = getReferenceElement({\n anchor,\n anchorRef,\n anchorRect,\n getAnchorRect,\n fallbackReferenceElement\n });\n refs.setReference(resultingReferenceElement);\n }, [anchor, anchorRef, anchorRefTop, anchorRefBottom, anchorRefStartContainer, anchorRefCurrent, anchorRect, getAnchorRect, fallbackReferenceElement, refs]);\n const mergedFloatingRef = useMergeRefs([refs.setFloating, dialogRef, forwardedRef]);\n const style = isExpanded ? undefined : {\n position: strategy,\n top: 0,\n left: 0,\n // `x` and `y` are framer-motion specific props and are shorthands\n // for `translateX` and `translateY`. Currently it is not possible\n // to use `translateX` and `translateY` because those values would\n // be overridden by the return value of the\n // `placementToMotionAnimationProps` function.\n x: computePopoverPosition(x),\n y: computePopoverPosition(y)\n };\n const shouldReduceMotion = useReducedMotion();\n const shouldAnimate = animate && !isExpanded && !shouldReduceMotion;\n const [animationFinished, setAnimationFinished] = useState(false);\n const {\n style: motionInlineStyles,\n ...otherMotionProps\n } = useMemo(() => placementToMotionAnimationProps(computedPlacement), [computedPlacement]);\n const animationProps = shouldAnimate ? {\n style: {\n ...contentStyle,\n ...motionInlineStyles,\n ...style\n },\n onAnimationComplete: () => setAnimationFinished(true),\n ...otherMotionProps\n } : {\n animate: false,\n style: {\n ...contentStyle,\n ...style\n }\n };\n\n // When Floating UI has finished positioning and Framer Motion has finished animating\n // the popover, add the `is-positioned` class to signal that all transitions have finished.\n const isPositioned = (!shouldAnimate || animationFinished) && x !== null && y !== null;\n let content = /*#__PURE__*/_jsxs(motion.div, {\n className: clsx(className, {\n 'is-expanded': isExpanded,\n 'is-positioned': isPositioned,\n // Use the 'alternate' classname for 'toolbar' variant for back compat.\n [`is-${computedVariant === 'toolbar' ? 'alternate' : computedVariant}`]: computedVariant\n }),\n ...animationProps,\n ...contentProps,\n ref: mergedFloatingRef,\n ...dialogProps,\n tabIndex: -1,\n children: [isExpanded && /*#__PURE__*/_jsx(ScrollLock, {}), isExpanded && /*#__PURE__*/_jsxs(\"div\", {\n className: \"components-popover__header\",\n children: [/*#__PURE__*/_jsx(\"span\", {\n className: \"components-popover__header-title\",\n children: headerTitle\n }), /*#__PURE__*/_jsx(Button, {\n className: \"components-popover__close\",\n size: \"small\",\n icon: close,\n onClick: onClose,\n label: __('Close')\n })]\n }), /*#__PURE__*/_jsx(\"div\", {\n className: \"components-popover__content\",\n children: children\n }), hasArrow && /*#__PURE__*/_jsx(\"div\", {\n ref: arrowCallbackRef,\n className: ['components-popover__arrow', `is-${computedPlacement.split('-')[0]}`].join(' '),\n style: {\n left: typeof arrowData?.x !== 'undefined' && Number.isFinite(arrowData.x) ? `${arrowData.x}px` : '',\n top: typeof arrowData?.y !== 'undefined' && Number.isFinite(arrowData.y) ? `${arrowData.y}px` : ''\n },\n children: /*#__PURE__*/_jsx(ArrowTriangle, {})\n })]\n });\n const shouldRenderWithinSlot = slot.ref && !inline;\n const hasAnchor = anchorRef || anchorRect || anchor;\n if (shouldRenderWithinSlot) {\n content = /*#__PURE__*/_jsx(Fill, {\n name: slotName,\n children: content\n });\n } else if (!inline) {\n content = createPortal(/*#__PURE__*/_jsx(StyleProvider, {\n document: document,\n children: content\n }), getPopoverFallbackContainer());\n }\n if (hasAnchor) {\n return content;\n }\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsx(\"span\", {\n ref: anchorRefFallback\n }), content]\n });\n};\n\n// Export the PopoverSlot individually to allow typescript to pick the types up.\nexport const PopoverSlot = forwardRef(({\n name = SLOT_NAME\n}, ref) => {\n return /*#__PURE__*/_jsx(Slot, {\n bubblesVirtually: true,\n name: name,\n className: \"popover-slot\",\n ref: ref\n });\n});\n\n/**\n * `Popover` renders its content in a floating modal. If no explicit anchor is passed via props, it anchors to its parent element by default.\n *\n * ```jsx\n * import { Button, Popover } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyPopover = () => {\n * \tconst [ isVisible, setIsVisible ] = useState( false );\n * \tconst toggleVisible = () => {\n * \t\tsetIsVisible( ( state ) => ! state );\n * \t};\n *\n * \treturn (\n * \t\t<Button variant=\"secondary\" onClick={ toggleVisible }>\n * \t\t\tToggle Popover!\n * \t\t\t{ isVisible && <Popover>Popover is toggled!</Popover> }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n */\nexport const Popover = Object.assign(contextConnect(UnforwardedPopover, 'Popover'), {\n /**\n * Renders a slot that is used internally by Popover for rendering content.\n */\n Slot: Object.assign(PopoverSlot, {\n displayName: 'Popover.Slot'\n }),\n /**\n * Provides a context to manage popover slot names.\n *\n * This is marked as unstable and should not be used directly.\n */\n __unstableSlotNameProvider: Object.assign(slotNameContext.Provider, {\n displayName: 'Popover.__unstableSlotNameProvider'\n })\n});\nexport default Popover;"],
5
- "mappings": "AAIA,OAAO,UAAU;AACjB,SAAS,aAAa,QAAQ,gBAAgB,SAAS,iBAAiB,YAAY,YAAY,OAAO,UAAU,kBAAkB,YAAY;AAC/I,SAAS,cAAc;AAKvB,SAAS,QAAQ,iBAAiB,YAAY,eAAe,YAAY,SAAS,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as flipMiddleware, shift as shiftMiddleware, limitShift, autoUpdate, arrow, offset as offsetMiddleware, size } from '@floating-ui/react-dom';\nimport { motion } from 'framer-motion';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useLayoutEffect, forwardRef, createContext, useContext, useMemo, useState, useCallback, createPortal } from '@wordpress/element';\nimport { useReducedMotion, useViewportMatch, useMergeRefs, __experimentalUseDialog as useDialog } from '@wordpress/compose';\nimport { close } from '@wordpress/icons';\nimport deprecated from '@wordpress/deprecated';\nimport { Path, SVG } from '@wordpress/primitives';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport ScrollLock from '../scroll-lock';\nimport { Slot, Fill, useSlot } from '../slot-fill';\nimport { computePopoverPosition, positionToPlacement, placementToMotionAnimationProps, getReferenceElement } from './utils';\nimport { contextConnect, useContextSystem } from '../context';\nimport { overlayMiddlewares } from './overlay-middlewares';\nimport { StyleProvider } from '../style-provider';\n\n/**\n * Name of slot in which popover should fill.\n *\n * @type {string}\n */\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nexport const SLOT_NAME = 'Popover';\n\n/**\n * Virtual padding to account for overflow boundaries.\n *\n * @type {number}\n */\nconst OVERFLOW_PADDING = 8;\n\n// An SVG displaying a triangle facing down, filled with a solid\n// color and bordered in such a way to create an arrow-like effect.\n// Keeping the SVG's viewbox squared simplify the arrow positioning\n// calculations.\nconst ArrowTriangle = () => /*#__PURE__*/_jsxs(SVG, {\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 100 100\",\n className: \"components-popover__triangle\",\n role: \"presentation\",\n children: [/*#__PURE__*/_jsx(Path, {\n className: \"components-popover__triangle-bg\",\n d: \"M 0 0 L 50 50 L 100 0\"\n }), /*#__PURE__*/_jsx(Path, {\n className: \"components-popover__triangle-border\",\n d: \"M 0 0 L 50 50 L 100 0\",\n vectorEffect: \"non-scaling-stroke\"\n })]\n});\nconst slotNameContext = createContext(undefined);\nslotNameContext.displayName = '__unstableSlotNameContext';\nconst fallbackContainerClassname = 'components-popover__fallback-container';\nconst getPopoverFallbackContainer = () => {\n let container = document.body.querySelector('.' + fallbackContainerClassname);\n if (!container) {\n container = document.createElement('div');\n container.className = fallbackContainerClassname;\n document.body.append(container);\n }\n return container;\n};\nconst UnforwardedPopover = (props, forwardedRef) => {\n const {\n animate = true,\n headerTitle,\n constrainTabbing,\n onClose,\n children,\n className,\n noArrow = true,\n position,\n placement: placementProp = 'bottom-start',\n offset: offsetProp = 0,\n focusOnMount = 'firstElement',\n anchor,\n expandOnMobile,\n onFocusOutside,\n __unstableSlotName = SLOT_NAME,\n flip = true,\n resize = true,\n shift = false,\n inline = false,\n variant,\n style: contentStyle,\n // Deprecated props\n __unstableForcePosition,\n anchorRef,\n anchorRect,\n getAnchorRect,\n isAlternate,\n // Rest\n ...contentProps\n } = useContextSystem(props, 'Popover');\n let computedFlipProp = flip;\n let computedResizeProp = resize;\n if (__unstableForcePosition !== undefined) {\n deprecated('`__unstableForcePosition` prop in wp.components.Popover', {\n since: '6.1',\n version: '6.3',\n alternative: '`flip={ false }` and `resize={ false }`'\n });\n\n // Back-compat, set the `flip` and `resize` props\n // to `false` to replicate `__unstableForcePosition`.\n computedFlipProp = !__unstableForcePosition;\n computedResizeProp = !__unstableForcePosition;\n }\n if (anchorRef !== undefined) {\n deprecated('`anchorRef` prop in wp.components.Popover', {\n since: '6.1',\n alternative: '`anchor` prop'\n });\n }\n if (anchorRect !== undefined) {\n deprecated('`anchorRect` prop in wp.components.Popover', {\n since: '6.1',\n alternative: '`anchor` prop'\n });\n }\n if (getAnchorRect !== undefined) {\n deprecated('`getAnchorRect` prop in wp.components.Popover', {\n since: '6.1',\n alternative: '`anchor` prop'\n });\n }\n const computedVariant = isAlternate ? 'toolbar' : variant;\n if (isAlternate !== undefined) {\n deprecated('`isAlternate` prop in wp.components.Popover', {\n since: '6.2',\n alternative: \"`variant` prop with the `'toolbar'` value\"\n });\n }\n const arrowRef = useRef(null);\n const [fallbackReferenceElement, setFallbackReferenceElement] = useState(null);\n const anchorRefFallback = useCallback(node => {\n setFallbackReferenceElement(node);\n }, []);\n const isMobileViewport = useViewportMatch('medium', '<');\n const isExpanded = expandOnMobile && isMobileViewport;\n const hasArrow = !isExpanded && !noArrow;\n const normalizedPlacementFromProps = position ? positionToPlacement(position) : placementProp;\n const middleware = [...(placementProp === 'overlay' ? overlayMiddlewares() : []), offsetMiddleware(offsetProp), computedFlipProp && flipMiddleware(), computedResizeProp && size({\n padding: OVERFLOW_PADDING,\n apply(sizeProps) {\n var _refs$floating$curren;\n const {\n firstElementChild\n } = (_refs$floating$curren = refs.floating.current) !== null && _refs$floating$curren !== void 0 ? _refs$floating$curren : {};\n\n // Only HTMLElement instances have the `style` property.\n if (!(firstElementChild instanceof HTMLElement)) {\n return;\n }\n\n // Reduce the height of the popover to the available space.\n Object.assign(firstElementChild.style, {\n maxHeight: `${Math.max(0, sizeProps.availableHeight)}px`,\n overflow: 'auto'\n });\n }\n }), shift && shiftMiddleware({\n crossAxis: true,\n limiter: limitShift(),\n padding: 1 // Necessary to avoid flickering at the edge of the viewport.\n }), arrow({\n element: arrowRef\n })];\n const slotName = useContext(slotNameContext) || __unstableSlotName;\n const slot = useSlot(slotName);\n let onDialogClose;\n if (onClose || onFocusOutside) {\n onDialogClose = (type, event) => {\n // Ideally the popover should have just a single onClose prop and\n // not three props that potentially do the same thing.\n if (type === 'focus-outside') {\n // Check if this blur event is actually relevant to this popover\n const blurTarget = event?.target;\n const referenceElement = refs.reference.current;\n const floatingElement = refs.floating.current;\n\n // Check if blur is from this popover's reference element or its floating content\n const isBlurFromThisPopover = referenceElement && 'contains' in referenceElement && referenceElement.contains(blurTarget) || floatingElement?.contains(blurTarget);\n // Ignore blur events that don't originate from this popover when there's no\n // relatedTarget (next focus target) and focus moves to document.body.\n // This prevents incorrectly closing the popover when clicking on elements\n // that don't accept focus (like clicking outside to empty space).\n const ownerDocument = floatingElement?.ownerDocument;\n if (!isBlurFromThisPopover && !('relatedTarget' in event && event.relatedTarget) && ownerDocument?.activeElement === ownerDocument?.body) {\n return;\n }\n // Call onFocusOutside if defined or call onClose.\n if (onFocusOutside) {\n onFocusOutside(event);\n } else if (onClose) {\n onClose();\n }\n } else if (onClose) {\n // onClose should be called for other event types if it exists.\n onClose();\n }\n };\n }\n const [dialogRef, dialogProps] = useDialog({\n constrainTabbing,\n focusOnMount,\n __unstableOnClose: onDialogClose,\n // @ts-expect-error The __unstableOnClose property needs to be deprecated first (see https://github.com/WordPress/gutenberg/pull/27675)\n onClose: onDialogClose\n });\n const {\n // Positioning coordinates\n x,\n y,\n // Object with \"regular\" refs to both \"reference\" and \"floating\"\n refs,\n // Type of CSS position property to use (absolute or fixed)\n strategy,\n update,\n placement: computedPlacement,\n middlewareData: {\n arrow: arrowData\n }\n } = useFloating({\n placement: normalizedPlacementFromProps === 'overlay' ? undefined : normalizedPlacementFromProps,\n middleware,\n whileElementsMounted: (referenceParam, floatingParam, updateParam) => autoUpdate(referenceParam, floatingParam, updateParam, {\n layoutShift: false,\n animationFrame: true\n })\n });\n const arrowCallbackRef = useCallback(node => {\n arrowRef.current = node;\n update();\n }, [update]);\n\n // When any of the possible anchor \"sources\" change,\n // recompute the reference element (real or virtual) and its owner document.\n\n const anchorRefTop = anchorRef?.top;\n const anchorRefBottom = anchorRef?.bottom;\n const anchorRefStartContainer = anchorRef?.startContainer;\n const anchorRefCurrent = anchorRef?.current;\n useLayoutEffect(() => {\n const resultingReferenceElement = getReferenceElement({\n anchor,\n anchorRef,\n anchorRect,\n getAnchorRect,\n fallbackReferenceElement\n });\n refs.setReference(resultingReferenceElement);\n }, [anchor, anchorRef, anchorRefTop, anchorRefBottom, anchorRefStartContainer, anchorRefCurrent, anchorRect, getAnchorRect, fallbackReferenceElement, refs]);\n const mergedFloatingRef = useMergeRefs([refs.setFloating, dialogRef, forwardedRef]);\n const style = isExpanded ? undefined : {\n position: strategy,\n top: 0,\n left: 0,\n // `x` and `y` are framer-motion specific props and are shorthands\n // for `translateX` and `translateY`. Currently it is not possible\n // to use `translateX` and `translateY` because those values would\n // be overridden by the return value of the\n // `placementToMotionAnimationProps` function.\n x: computePopoverPosition(x),\n y: computePopoverPosition(y)\n };\n const shouldReduceMotion = useReducedMotion();\n const shouldAnimate = animate && !isExpanded && !shouldReduceMotion;\n const [animationFinished, setAnimationFinished] = useState(false);\n const {\n style: motionInlineStyles,\n ...otherMotionProps\n } = useMemo(() => placementToMotionAnimationProps(computedPlacement), [computedPlacement]);\n const animationProps = shouldAnimate ? {\n style: {\n ...contentStyle,\n ...motionInlineStyles,\n ...style\n },\n onAnimationComplete: () => setAnimationFinished(true),\n ...otherMotionProps\n } : {\n animate: false,\n style: {\n ...contentStyle,\n ...style\n }\n };\n\n // When Floating UI has finished positioning and Framer Motion has finished animating\n // the popover, add the `is-positioned` class to signal that all transitions have finished.\n const isPositioned = (!shouldAnimate || animationFinished) && x !== null && y !== null;\n let content = /*#__PURE__*/_jsxs(motion.div, {\n className: clsx(className, {\n 'is-expanded': isExpanded,\n 'is-positioned': isPositioned,\n // Use the 'alternate' classname for 'toolbar' variant for back compat.\n [`is-${computedVariant === 'toolbar' ? 'alternate' : computedVariant}`]: computedVariant\n }),\n ...animationProps,\n ...contentProps,\n ref: mergedFloatingRef,\n ...dialogProps,\n tabIndex: -1,\n children: [isExpanded && /*#__PURE__*/_jsx(ScrollLock, {}), isExpanded && /*#__PURE__*/_jsxs(\"div\", {\n className: \"components-popover__header\",\n children: [/*#__PURE__*/_jsx(\"span\", {\n className: \"components-popover__header-title\",\n children: headerTitle\n }), /*#__PURE__*/_jsx(Button, {\n className: \"components-popover__close\",\n size: \"small\",\n icon: close,\n onClick: onClose,\n label: __('Close')\n })]\n }), /*#__PURE__*/_jsx(\"div\", {\n className: \"components-popover__content\",\n children: children\n }), hasArrow && /*#__PURE__*/_jsx(\"div\", {\n ref: arrowCallbackRef,\n className: ['components-popover__arrow', `is-${computedPlacement.split('-')[0]}`].join(' '),\n style: {\n left: typeof arrowData?.x !== 'undefined' && Number.isFinite(arrowData.x) ? `${arrowData.x}px` : '',\n top: typeof arrowData?.y !== 'undefined' && Number.isFinite(arrowData.y) ? `${arrowData.y}px` : ''\n },\n children: /*#__PURE__*/_jsx(ArrowTriangle, {})\n })]\n });\n const shouldRenderWithinSlot = slot.ref && !inline;\n const hasAnchor = anchorRef || anchorRect || anchor;\n if (shouldRenderWithinSlot) {\n content = /*#__PURE__*/_jsx(Fill, {\n name: slotName,\n children: content\n });\n } else if (!inline) {\n content = createPortal(/*#__PURE__*/_jsx(StyleProvider, {\n document: document,\n children: content\n }), getPopoverFallbackContainer());\n }\n if (hasAnchor) {\n return content;\n }\n return /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsx(\"span\", {\n ref: anchorRefFallback\n }), content]\n });\n};\n\n// Export the PopoverSlot individually to allow typescript to pick the types up.\nexport const PopoverSlot = forwardRef(({\n name = SLOT_NAME\n}, ref) => {\n return /*#__PURE__*/_jsx(Slot, {\n bubblesVirtually: true,\n name: name,\n className: \"popover-slot\",\n ref: ref\n });\n});\n\n/**\n * `Popover` renders its content in a floating modal. If no explicit anchor is passed via props, it anchors to its parent element by default.\n *\n * ```jsx\n * import { Button, Popover } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyPopover = () => {\n * \tconst [ isVisible, setIsVisible ] = useState( false );\n * \tconst toggleVisible = () => {\n * \t\tsetIsVisible( ( state ) => ! state );\n * \t};\n *\n * \treturn (\n * \t\t<Button variant=\"secondary\" onClick={ toggleVisible }>\n * \t\t\tToggle Popover!\n * \t\t\t{ isVisible && <Popover>Popover is toggled!</Popover> }\n * \t\t</Button>\n * \t);\n * };\n * ```\n *\n */\nexport const Popover = Object.assign(contextConnect(UnforwardedPopover, 'Popover'), {\n /**\n * Renders a slot that is used internally by Popover for rendering content.\n */\n Slot: Object.assign(PopoverSlot, {\n displayName: 'Popover.Slot'\n }),\n /**\n * Provides a context to manage popover slot names.\n *\n * This is marked as unstable and should not be used directly.\n */\n __unstableSlotNameProvider: Object.assign(slotNameContext.Provider, {\n displayName: 'Popover.__unstableSlotNameProvider'\n })\n});\nexport default Popover;"],
5
+ "mappings": "AAIA,OAAO,UAAU;AACjB,SAAS,aAAa,QAAQ,gBAAgB,SAAS,iBAAiB,YAAY,YAAY,OAAO,UAAU,kBAAkB,YAAY;AAC/I,SAAS,cAAc;AAKvB,SAAS,QAAQ,iBAAiB,YAAY,eAAe,YAAY,SAAS,UAAU,aAAa,oBAAoB;AAC7H,SAAS,kBAAkB,kBAAkB,cAAc,2BAA2B,iBAAiB;AACvG,SAAS,aAAa;AACtB,OAAO,gBAAgB;AACvB,SAAS,MAAM,WAAW;AAC1B,SAAS,UAAU;AAKnB,OAAO,YAAY;AACnB,OAAO,gBAAgB;AACvB,SAAS,MAAM,MAAM,eAAe;AACpC,SAAS,wBAAwB,qBAAqB,iCAAiC,2BAA2B;AAClH,SAAS,gBAAgB,wBAAwB;AACjD,SAAS,0BAA0B;AACnC,SAAS,qBAAqB;AAO9B,SAAS,OAAO,MAAM,QAAQ,OAAO,YAAY,iBAAiB;AAC3D,MAAM,YAAY;AAOzB,MAAM,mBAAmB;AAMzB,MAAM,gBAAgB,MAAmB,sBAAM,KAAK;AAAA,EAClD,OAAO;AAAA,EACP,SAAS;AAAA,EACT,WAAW;AAAA,EACX,MAAM;AAAA,EACN,UAAU,CAAc,qBAAK,MAAM;AAAA,IACjC,WAAW;AAAA,IACX,GAAG;AAAA,EACL,CAAC,GAAgB,qBAAK,MAAM;AAAA,IAC1B,WAAW;AAAA,IACX,GAAG;AAAA,IACH,cAAc;AAAA,EAChB,CAAC,CAAC;AACJ,CAAC;AACD,MAAM,kBAAkB,cAAc,MAAS;AAC/C,gBAAgB,cAAc;AAC9B,MAAM,6BAA6B;AACnC,MAAM,8BAA8B,MAAM;AACxC,MAAI,YAAY,SAAS,KAAK,cAAc,MAAM,0BAA0B;AAC5E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A,MAAI,WAAW;AACb,WAAO;AAAA,EACT;AACA,SAAoB,sBAAM,WAAW;AAAA,IACnC,UAAU,CAAc,qBAAK,QAAQ;AAAA,MACnC,KAAK;AAAA,IACP,CAAC,GAAG,OAAO;AAAA,EACb,CAAC;AACH;AAGO,MAAM,cAAc,WAAW,CAAC;AAAA,EACrC,OAAO;AACT,GAAG,QAAQ;AACT,SAAoB,qBAAK,MAAM;AAAA,IAC7B,kBAAkB;AAAA,IAClB;AAAA,IACA,WAAW;AAAA,IACX;AAAA,EACF,CAAC;AACH,CAAC;AAyBM,MAAM,UAAU,OAAO,OAAO,eAAe,oBAAoB,SAAS,GAAG;AAAA;AAAA;AAAA;AAAA,EAIlF,MAAM,OAAO,OAAO,aAAa;AAAA,IAC/B,aAAa;AAAA,EACf,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMD,4BAA4B,OAAO,OAAO,gBAAgB,UAAU;AAAA,IAClE,aAAa;AAAA,EACf,CAAC;AACH,CAAC;AACD,IAAO,kBAAQ;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/popover/index.tsx"],"names":[],"mappings":"AAwDA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EACX,YAAY,EAGZ,gBAAgB,EAChB,MAAM,SAAS,CAAC;AAIjB;;;;GAIG;AACH,eAAO,MAAM,SAAS,YAAY,CAAC;AAuanC,eAAO,MAAM,WAAW,6GAWvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,OAAO;IAGlB;;OAEG;;;;IAIH;;;;OAIG;;;;CAKJ,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/popover/index.tsx"],"names":[],"mappings":"AAwDA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EACX,YAAY,EAGZ,gBAAgB,EAChB,MAAM,SAAS,CAAC;AAIjB;;;;GAIG;AACH,eAAO,MAAM,SAAS,YAAY,CAAC;AAocnC,eAAO,MAAM,WAAW,6GAWvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,OAAO;IAGlB;;OAEG;;;;IAIH;;;;OAIG;;;;CAKJ,CAAC;AAEF,eAAe,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/components",
3
- "version": "30.6.4",
3
+ "version": "30.6.5",
4
4
  "description": "UI components for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -97,5 +97,5 @@
97
97
  "publishConfig": {
98
98
  "access": "public"
99
99
  },
100
- "gitHead": "e821b2ec0a90d60aa7cafc248ba049f13b4265b7"
100
+ "gitHead": "ece3841462592f9e9b99cfa7cac0fe98bdce8fd7"
101
101
  }
@@ -268,9 +268,38 @@ const UnforwardedPopover = (
268
268
  onDialogClose = ( type: string | undefined, event: SyntheticEvent ) => {
269
269
  // Ideally the popover should have just a single onClose prop and
270
270
  // not three props that potentially do the same thing.
271
- if ( type === 'focus-outside' && onFocusOutside ) {
272
- onFocusOutside( event );
271
+ if ( type === 'focus-outside' ) {
272
+ // Check if this blur event is actually relevant to this popover
273
+ const blurTarget = event?.target as Element;
274
+ const referenceElement = refs.reference.current;
275
+ const floatingElement = refs.floating.current;
276
+
277
+ // Check if blur is from this popover's reference element or its floating content
278
+ const isBlurFromThisPopover =
279
+ ( referenceElement &&
280
+ 'contains' in referenceElement &&
281
+ referenceElement.contains( blurTarget ) ) ||
282
+ floatingElement?.contains( blurTarget );
283
+ // Ignore blur events that don't originate from this popover when there's no
284
+ // relatedTarget (next focus target) and focus moves to document.body.
285
+ // This prevents incorrectly closing the popover when clicking on elements
286
+ // that don't accept focus (like clicking outside to empty space).
287
+ const ownerDocument = floatingElement?.ownerDocument;
288
+ if (
289
+ ! isBlurFromThisPopover &&
290
+ ! ( 'relatedTarget' in event && event.relatedTarget ) &&
291
+ ownerDocument?.activeElement === ownerDocument?.body
292
+ ) {
293
+ return;
294
+ }
295
+ // Call onFocusOutside if defined or call onClose.
296
+ if ( onFocusOutside ) {
297
+ onFocusOutside( event );
298
+ } else if ( onClose ) {
299
+ onClose();
300
+ }
273
301
  } else if ( onClose ) {
302
+ // onClose should be called for other event types if it exists.
274
303
  onClose();
275
304
  }
276
305
  };
@@ -578,4 +578,89 @@ describe( 'Popover', () => {
578
578
  }
579
579
  );
580
580
  } );
581
+
582
+ describe( 'closing all nested popovers', () => {
583
+ // Test component that simulates the nested popover scenario:
584
+ // A parent popover (like ColorGradient dropdown) containing a trigger
585
+ // that opens a nested popover (like custom color picker dropdown)
586
+ function NestedPopoverTestComponent( {
587
+ onParentFocusOutside,
588
+ onNestedFocusOutside,
589
+ }: {
590
+ onParentFocusOutside: jest.Mock;
591
+ onNestedFocusOutside: jest.Mock;
592
+ } ) {
593
+ const [ isNestedOpen, setIsNestedOpen ] = useState( false );
594
+
595
+ return (
596
+ <>
597
+ <button data-testid="external-button">
598
+ External Button
599
+ </button>
600
+ <Popover
601
+ data-testid="parent-popover"
602
+ onFocusOutside={ onParentFocusOutside }
603
+ focusOnMount={ false }
604
+ >
605
+ <button
606
+ data-testid="parent-button"
607
+ onClick={ () => setIsNestedOpen( ! isNestedOpen ) }
608
+ >
609
+ Open Nested
610
+ </button>
611
+ { isNestedOpen && (
612
+ <Popover
613
+ data-testid="nested-popover"
614
+ onFocusOutside={ onNestedFocusOutside }
615
+ focusOnMount={ false }
616
+ >
617
+ <button data-testid="nested-dummy-button">
618
+ Nested Dummy Button
619
+ </button>
620
+ </Popover>
621
+ ) }
622
+ </Popover>
623
+ </>
624
+ );
625
+ }
626
+
627
+ it( 'should call parent onFocusOutside when focus moves from nested popover to external element', async () => {
628
+ const user = userEvent.setup();
629
+ const onParentFocusOutside = jest.fn();
630
+ const onNestedFocusOutside = jest.fn();
631
+
632
+ render(
633
+ <NestedPopoverTestComponent
634
+ onParentFocusOutside={ onParentFocusOutside }
635
+ onNestedFocusOutside={ onNestedFocusOutside }
636
+ />
637
+ );
638
+
639
+ await waitFor( () => {
640
+ expect(
641
+ screen.getByTestId( 'parent-popover' )
642
+ ).toBeInTheDocument();
643
+ } );
644
+
645
+ await user.click( screen.getByTestId( 'parent-button' ) );
646
+
647
+ await waitFor( () => {
648
+ expect(
649
+ screen.getByTestId( 'nested-popover' )
650
+ ).toBeInTheDocument();
651
+ } );
652
+
653
+ await user.click( screen.getByTestId( 'nested-dummy-button' ) );
654
+
655
+ await user.click( screen.getByTestId( 'external-button' ) );
656
+
657
+ await waitFor( () => {
658
+ expect( onNestedFocusOutside ).toHaveBeenCalledTimes( 1 );
659
+ } );
660
+
661
+ await waitFor( () => {
662
+ expect( onParentFocusOutside ).toHaveBeenCalledTimes( 1 );
663
+ } );
664
+ } );
665
+ } );
581
666
  } );