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

Popover: deprecate the position prop #44386

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Deprecations

- `Popover`: added new `anchor` prop, supposed to supersede all previous anchor-related props (`anchorRef`, `anchorRect`, `getAnchorRect`). These older anchor-related props are now marked as deprecated and are scheduled to be removed in WordPress 6.3 ([#43691](https://github.com/WordPress/gutenberg/pull/43691)).
- `Popover`: deprecate the legacy `position` prop, in favor of the newer `placement` prop. The `position` prop is scheduled to be removed in WordPress 6.4 ([#44386](https://github.com/WordPress/gutenberg/pull/44386)).

### Bug Fix

Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/popover/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Used to specify the popover's position with respect to its anchor.

### `position`: `[yAxis] [xAxis] [optionalCorner]`

_Note: use the `placement` prop instead when possible._
_Note: this prop is deprecated and will be removed in WordPress 6.4. Please use the `placement` prop instead._

Legacy way to specify the popover's position with respect to its anchor.

Expand All @@ -213,7 +213,6 @@ Possible values:
- `xAxis`: `'left' | 'center' | 'right'`
- `corner`: `'top' | 'right' | 'bottom' | 'left'`


- Required: No

### `resize`: `boolean`
Expand Down
10 changes: 9 additions & 1 deletion packages/components/src/popover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ const UnforwardedPopover = (
className,
noArrow = true,
isAlternate,
position,
placement: placementProp = 'bottom-start',
offset: offsetProp = 0,
focusOnMount = 'firstElement',
Expand All @@ -188,6 +187,7 @@ const UnforwardedPopover = (
anchorRef,
anchorRect,
getAnchorRect,
position,
range,

// Rest
Expand Down Expand Up @@ -252,6 +252,14 @@ const UnforwardedPopover = (
} );
}

if ( position !== undefined ) {
deprecated( '`position` prop in wp.components.Popover', {
since: '6.2',
version: '6.4',
alternative: '`placement` prop',
} );
}

const arrowRef = useRef( null );

const [ fallbackReferenceElement, setFallbackReferenceElement ] =
Expand Down
16 changes: 9 additions & 7 deletions packages/components/src/popover/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,6 @@ export type PopoverProps = {
* @default 'bottom-start'
*/
placement?: Placement;
/**
* Legacy way to specify the popover's position with respect to its anchor.
* _Note: this prop is deprecated. Use the `placement` prop instead._
*/
position?:
| `${ PositionYAxis } ${ PositionXAxis }`
| `${ PositionYAxis } ${ PositionXAxis } ${ PositionCorner }`;
/**
* Adjusts the size of the popover to prevent its contents from going out of
* view when meeting the viewport edges.
Expand Down Expand Up @@ -189,4 +182,13 @@ export type PopoverProps = {
* @deprecated
*/
range?: unknown;
/**
* Legacy way to specify the popover's position with respect to its anchor.
* _Note: this prop is deprecated. Use the `placement` prop instead._
*
* @deprecated
*/
position?:
| `${ PositionYAxis } ${ PositionXAxis }`
| `${ PositionYAxis } ${ PositionXAxis } ${ PositionCorner }`;
};