Skip to content

Commit

Permalink
Fix popover deprecations (#45195)
Browse files Browse the repository at this point in the history
* Fix popover deprecations

* Also remove from docs and types

* Update changelog

* Update packages/components/CHANGELOG.md

Co-authored-by: Marco Ciampini <[email protected]>
  • Loading branch information
2 people authored and Mamaduka committed Nov 10, 2022
1 parent 46c6b4b commit da52b5f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 48 deletions.
19 changes: 19 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

## Unreleased

<<<<<<< HEAD
=======
### Breaking Changes

- `Popover`: The deprecated `range` and `__unstableShift` props have been removed ([#45195](https://github.com/WordPress/gutenberg/pull/45195)).

### Deprecations

- `Popover`: the deprecation messages for anchor-related props (`anchorRef`, `anchorRect`, `getAnchorRect`) have been updated. ([#45195](https://github.com/WordPress/gutenberg/pull/45195)).

### New Feature

- `BoxControl` & `CustomSelectControl`: Add `onMouseOver` and `onMouseOut` callback props to allow handling of these events by parent components ([#44955](https://github.com/WordPress/gutenberg/pull/44955))

## Enhancements

- `FontSizePicker`: Improved slider design when `withSlider` is set ([#44598](https://github.com/WordPress/gutenberg/pull/44598)).

>>>>>>> 00e632aff9 (Fix popover deprecations (#45195))
### Bug Fix

- `FontSizePicker`: Ensure that fluid font size presets appear correctly in the UI controls ([#44791](https://github.com/WordPress/gutenberg/pull/44791))
Expand Down
12 changes: 3 additions & 9 deletions packages/components/src/popover/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ The element should be stored in state rather than a plain ref to ensure reactive

### `anchorRect`: `DomRectWithOwnerDocument`

_Note: this prop is deprecated and will be removed in WordPress 6.3. Please use the `anchor` prop instead._
_Note: this prop is deprecated. Please use the `anchor` prop instead._

An object extending a `DOMRect` with an additional optional `ownerDocument` property, used to specify a fixed popover position.

- Required: No

### `anchorRef`: `Element | PopoverAnchorRefReference | PopoverAnchorRefTopBottom | Range`

_Note: this prop is deprecated and will be removed in WordPress 6.3. Please use the `anchor` prop instead._
_Note: this prop is deprecated. Please use the `anchor` prop instead._

Used to specify a fixed popover position. It can be an `Element`, a React reference to an `element`, an object with a `top` and a `bottom` properties (both pointing to elements), or a `range`.

Expand Down Expand Up @@ -157,7 +157,7 @@ When not provided, the `onClose` callback will be called instead.

### `getAnchorRect`: `( fallbackReferenceElement: Element | null ) => DomRectWithOwnerDocument`

_Note: this prop is deprecated and will be removed in WordPress 6.3. Please use the `anchor` prop instead._
_Note: this prop is deprecated. Please use the `anchor` prop instead._

A function returning the same value as the one expected by the `anchorRect` prop, used to specify a dynamic popover position.

Expand Down Expand Up @@ -222,9 +222,3 @@ Adjusts the size of the popover to prevent its contents from going out of view w

- Required: No
- Default: `true`

### `range`: `unknown`

_Note: this prop is deprecated and will be removed in WordPress 6.3. It has no effect on the component._

- Required: No
26 changes: 1 addition & 25 deletions packages/components/src/popover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,23 +184,14 @@ const UnforwardedPopover = (

// Deprecated props
__unstableForcePosition,
__unstableShift,
anchorRef,
anchorRect,
getAnchorRect,
range,

// Rest
...contentProps
} = props;

if ( range ) {
deprecated( '`range` prop in wp.components.Popover', {
since: '6.1',
version: '6.3',
} );
}

let computedFlipProp = flip;
let computedResizeProp = resize;
if ( __unstableForcePosition !== undefined ) {
Expand All @@ -216,38 +207,23 @@ const UnforwardedPopover = (
computedResizeProp = ! __unstableForcePosition;
}

let shouldShift = shift;
if ( __unstableShift !== undefined ) {
deprecated( '`__unstableShift` prop in wp.components.Popover', {
since: '6.1',
version: '6.3',
alternative: '`shift` prop`',
} );

// Back-compat.
shouldShift = __unstableShift;
}

if ( anchorRef !== undefined ) {
deprecated( '`anchorRef` prop in wp.components.Popover', {
since: '6.1',
version: '6.3',
alternative: '`anchor` prop',
} );
}

if ( anchorRect !== undefined ) {
deprecated( '`anchorRect` prop in wp.components.Popover', {
since: '6.1',
version: '6.3',
alternative: '`anchor` prop',
} );
}

if ( getAnchorRect !== undefined ) {
deprecated( '`getAnchorRect` prop in wp.components.Popover', {
since: '6.1',
version: '6.3',
alternative: '`anchor` prop',
} );
}
Expand Down Expand Up @@ -325,7 +301,7 @@ const UnforwardedPopover = (
},
} )
: undefined,
shouldShift
shift
? shiftMiddleware( {
crossAxis: true,
limiter: customLimitShift(),
Expand Down
14 changes: 0 additions & 14 deletions packages/components/src/popover/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,6 @@ export type PopoverProps = {
* @deprecated
*/
__unstableForcePosition?: boolean;
/**
* Enables the `Popover` to shift in order to stay in view when meeting the
* viewport edges.
* _Note: this prop is deprecated. Use the `shift` prop instead._
*
* @deprecated
*/
__unstableShift?: boolean;
/**
* An object extending a `DOMRect` with an additional optional `ownerDocument`
* property, used to specify a fixed popover position.
Expand Down Expand Up @@ -183,10 +175,4 @@ export type PopoverProps = {
getAnchorRect?: (
fallbackReferenceElement: Element | null
) => DomRectWithOwnerDocument;
/**
* _Note: this prop is deprecated and has no effect on the component._
*
* @deprecated
*/
range?: unknown;
};

0 comments on commit da52b5f

Please sign in to comment.