Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix popover deprecations #45195

Merged
merged 4 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unreleased

### 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))
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 @@ -148,14 +148,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 @@ -184,10 +176,4 @@ export type PopoverProps = {
getAnchorRect?: (
fallbackReferenceElement: Element | null
) => DomRectWithOwnerDocument;
/**
* _Note: this prop is deprecated and has no effect on the component._
*
* @deprecated
*/
range?: unknown;
};