Skip to content

Commit

Permalink
Revert "Rename and stabilize __experimentalPopoverPositionToPlacement"
Browse files Browse the repository at this point in the history
This reverts commit 0d0a7aa.
  • Loading branch information
ciampo committed Feb 1, 2023
1 parent 0c7cc68 commit 35e8dc7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/url-popover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useState } from '@wordpress/element';
import {
Button,
Popover,
popoverLegacyPositionToPlacement,
__experimentalPopoverPositionToPlacement as positionToPlacement,
} from '@wordpress/components';
import { chevronDown } from '@wordpress/icons';
import deprecated from '@wordpress/deprecated';
Expand Down Expand Up @@ -46,7 +46,7 @@ function URLPopover( {
if ( placement !== undefined ) {
computedPlacement = placement;
} else if ( position !== undefined ) {
computedPlacement = popoverLegacyPositionToPlacement( position );
computedPlacement = positionToPlacement( position );
}
computedPlacement = computedPlacement || DEFAULT_PLACEMENT;

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export { default as PanelHeader } from './panel/header';
export { default as PanelRow } from './panel/row';
export { default as Placeholder } from './placeholder';
export { default as Popover } from './popover';
export { popoverLegacyPositionToPlacement } from './popover/utils';
export { positionToPlacement as __experimentalPopoverPositionToPlacement } from './popover/utils';
export { default as QueryControls } from './query-controls';
export { default as __experimentalRadio } from './radio-group/radio';
export { default as __experimentalRadioGroup } from './radio-group';
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/popover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import ScrollLock from '../scroll-lock';
import { Slot, Fill, useSlot } from '../slot-fill';
import {
getFrameOffset,
popoverLegacyPositionToPlacement,
positionToPlacement,
placementToMotionAnimationProps,
getReferenceOwnerDocument,
getReferenceElement,
Expand Down Expand Up @@ -256,7 +256,7 @@ const UnforwardedPopover = (
const isExpanded = expandOnMobile && isMobileViewport;
const hasArrow = ! isExpanded && ! noArrow;
const normalizedPlacementFromProps = position
? popoverLegacyPositionToPlacement( position )
? positionToPlacement( position )
: placementProp;

/**
Expand Down
5 changes: 3 additions & 2 deletions packages/components/src/popover/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ const POSITION_TO_PLACEMENT: Record<
};

/**
* Converts the `Popover`'s legacy "position" prop to the new "placement" prop.
* Converts the `Popover`'s legacy "position" prop to the new "placement" prop
* (used by `floating-ui`).
*
* @param position The legacy position
* @return The corresponding placement
*/
export const popoverLegacyPositionToPlacement = (
export const positionToPlacement = (
position: NonNullable< PopoverProps[ 'position' ] >
): NonNullable< PopoverProps[ 'placement' ] > =>
POSITION_TO_PLACEMENT[ position ] ?? 'bottom';
Expand Down

0 comments on commit 35e8dc7

Please sign in to comment.