diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 4196d8be8f5524..2fbc3447917a1e 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -8,6 +8,7 @@ - `BorderControl`: Ensure box-sizing is reset for the control ([#42754](https://github.com/WordPress/gutenberg/pull/42754)). - `InputControl`: Fix acceptance of falsy values in controlled updates ([#42484](https://github.com/WordPress/gutenberg/pull/42484/)). - `Tooltip (Experimental)`, `CustomSelectControl`, `TimePicker`: Add missing font-size styles which were necessary in non-WordPress contexts ([#42844](https://github.com/WordPress/gutenberg/pull/42844/)). +- `Popover`: fix arrow placement and design ([#42874](https://github.com/WordPress/gutenberg/pull/42874/)). ### Enhancements diff --git a/packages/components/src/popover/index.js b/packages/components/src/popover/index.js index 0b9e3f0a981772..c3f56c93895fe5 100644 --- a/packages/components/src/popover/index.js +++ b/packages/components/src/popover/index.js @@ -32,6 +32,7 @@ import { } from '@wordpress/compose'; import { close } from '@wordpress/icons'; import deprecated from '@wordpress/deprecated'; +import { Path, SVG } from '@wordpress/primitives'; /** * Internal dependencies @@ -48,6 +49,30 @@ import { getAnimateClassName } from '../animate'; */ const SLOT_NAME = 'Popover'; +// An SVG displaying a triangle facing down, filled with a solid +// color and bordered in such a way to create an arrow-like effect. +// Keeping the SVG's viewbox squared simplify the arrow positioning +// calculations. +const ArrowTriangle = ( props ) => ( + +); + const slotNameContext = createContext(); const positionToPlacement = ( position ) => { @@ -266,12 +291,7 @@ const Popover = ( placement: usedPlacement, middleware: middlewares, } ); - const staticSide = { - top: 'bottom', - right: 'left', - bottom: 'top', - left: 'right', - }[ placementData.split( '-' )[ 0 ] ]; + const mergedRefs = useMergeRefs( [ floating, dialogRef, ref ] ); // Updates references @@ -407,22 +427,22 @@ const Popover = (