Skip to content

Commit

Permalink
chore(Popover): remove deprecated props (patternfly#8201)
Browse files Browse the repository at this point in the history
* chore(Popover): remove deprecated props

* remove TippyInstance props
  • Loading branch information
tompsota authored and jenny-s51 committed Nov 1, 2022
1 parent d4130e5 commit 0f60005
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ const DatePickerBase = (
}
showClose={false}
isVisible={popoverOpen}
shouldClose={(_1, _2, event) => {
shouldClose={(_1, event) => {
event = event as KeyboardEvent;
if (event.key === KeyTypes.Escape && selectOpen) {
event.stopPropagation();
Expand Down
42 changes: 10 additions & 32 deletions packages/react-core/src/components/Popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { ReactElement } from 'react';
import { FocusTrap } from '../../helpers';
import { Popper, getOpacityTransition } from '../../helpers/Popper/Popper';
import { getUniqueId } from '../../helpers/util';
import { Instance as TippyInstance, Props as TippyProps } from '../../helpers/Popper/DeprecatedTippyTypes';

export enum PopoverPosition {
auto = 'auto',
Expand Down Expand Up @@ -60,10 +59,6 @@ export interface PopoverProps {
* bodyContent={hide => <Button onClick={() => hide()}>Close</Button>}
*/
bodyContent: React.ReactNode | ((hide: () => void) => React.ReactNode);
/** @deprecated - no longer used. if you want to constrain the popper to a specific element
* use the appendTo prop instead.
*/
boundary?: 'scrollParent' | 'window' | 'viewport' | HTMLElement;
/**
* The reference element to which the popover is relatively placed to. If you cannot wrap
* the reference with the Popover, you can use the reference prop instead.
Expand Down Expand Up @@ -151,29 +146,24 @@ export interface PopoverProps {
minWidth?: string;
/**
* Lifecycle function invoked when the popover has fully transitioned out.
* Note: The tip argument is no longer passed and has been deprecated.
*/
onHidden?: (tip?: TippyInstance) => void;
onHidden?: () => void;
/**
* Lifecycle function invoked when the popover begins to transition out.
* Note: The tip argument is no longer passed and has been deprecated.
*/
onHide?: (tip?: TippyInstance) => void;
onHide?: () => void;
/**
* Lifecycle function invoked when the popover has been mounted to the DOM.
* Note: The tip argument is no longer passed and has been deprecated.
*/
onMount?: (tip?: TippyInstance) => void;
onMount?: () => void;
/**
* Lifecycle function invoked when the popover begins to transition in.
* Note: The tip argument is no longer passed and has been deprecated.
*/
onShow?: (tip?: TippyInstance) => void;
onShow?: () => void;
/**
* Lifecycle function invoked when the popover has fully transitioned in.
* Note: The tip argument is no longer passed and has been deprecated.
*/
onShown?: (tip?: TippyInstance) => void;
onShown?: () => void;
/**
* Popover position. Note: With the enableFlip property set to true, it will change the
* position if there is not enough space for the starting position. The behavior of where it
Expand Down Expand Up @@ -205,18 +195,15 @@ export interface PopoverProps {
/**
* Callback function that is only invoked when isVisible is also controlled. Called when the
* popover close button is clicked, the enter key was used on it, or the escape key is used.
* Note: The tip argument is no longer passed and has been deprecated.
*/
shouldClose?: (tip?: TippyInstance, hideFunction?: () => void, event?: MouseEvent | KeyboardEvent) => void;
shouldClose?: (hideFunction?: () => void, event?: MouseEvent | KeyboardEvent) => void;
/**
* Callback function that is only invoked when isVisible is also controlled. Called when the
* enter key is used on the focused trigger.
*/
shouldOpen?: (showFunction?: () => void, event?: MouseEvent | KeyboardEvent) => void;
/** Flag indicating whether the close button should be shown. */
showClose?: boolean;
/** @deprecated - no longer used. */
tippyProps?: Partial<TippyProps>;
/** Whether to trap focus in the popover. */
withFocusTrap?: boolean;
/** The z-index of the popover. */
Expand Down Expand Up @@ -277,21 +264,12 @@ export const Popover: React.FunctionComponent<PopoverProps> = ({
animationDuration = 300,
id,
withFocusTrap: propWithFocusTrap,
boundary,
tippyProps,
reference,
hasNoPadding = false,
hasAutoWidth = false,
removeFindDomNode = false,
...rest
}: PopoverProps) => {
if (process.env.NODE_ENV !== 'production') {
boundary !== undefined &&
console.warn(
'The Popover boundary prop has been deprecated. If you want to constrain the popper to a specific element use the appendTo prop instead.'
);
tippyProps !== undefined && console.warn('The Popover tippyProps prop has been deprecated and is no longer used.');
}
// could make this a prop in the future (true | false | 'toggle')
// const hideOnClick = true;
const uniqueId = id || getUniqueId();
Expand Down Expand Up @@ -363,7 +341,7 @@ export const Popover: React.FunctionComponent<PopoverProps> = ({
const onDocumentKeyDown = (event: KeyboardEvent) => {
if (event.key === KeyTypes.Escape && visible) {
if (triggerManually) {
shouldClose(null, hide, event);
shouldClose(hide, event);
} else {
hide();
}
Expand All @@ -378,7 +356,7 @@ export const Popover: React.FunctionComponent<PopoverProps> = ({
return;
}
if (triggerManually) {
shouldClose(null, hide, event);
shouldClose(hide, event);
} else {
hide();
}
Expand All @@ -387,7 +365,7 @@ export const Popover: React.FunctionComponent<PopoverProps> = ({
const onTriggerClick = (event: MouseEvent) => {
if (triggerManually) {
if (visible) {
shouldClose(null, hide, event);
shouldClose(hide, event);
} else {
shouldOpen(show, event);
}
Expand All @@ -407,7 +385,7 @@ export const Popover: React.FunctionComponent<PopoverProps> = ({
const closePopover = (event: any) => {
event.stopPropagation();
if (triggerManually) {
shouldClose(null, hide, event);
shouldClose(hide, event);
} else {
hide();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Popover } from '@patternfly/react-core';
import React, { Component } from 'react';
import { Instance as TippyInstance } from '@patternfly/react-core/dist/esm/helpers/Popper/DeprecatedTippyTypes';

export class PopoverDemo extends Component {
popoverRef: React.RefObject<HTMLButtonElement>;
Expand Down Expand Up @@ -30,13 +29,6 @@ export class PopoverDemo extends Component {
>
{this.myPopoverProps.children}
</Popover>
<Popover
bodyContent="test deprecated props"
tippyProps={{ duration: 0, delay: 0 }}
shouldClose={(tip: TippyInstance) => !tip}
>
<button>Trigger</button>
</Popover>
<div>
<button id="popover-selector">Popover attached via selector ref</button>
<Popover
Expand Down

0 comments on commit 0f60005

Please sign in to comment.