1414 * limitations under the License.
1515 */
1616
17- import type { State as PopperState , PositioningStrategy } from "@popperjs/core" ;
17+ import type { State as PopperState } from "@popperjs/core" ;
1818import classNames from "classnames" ;
1919import { Children , cloneElement , createElement , createRef } from "react" ;
2020import {
@@ -38,92 +38,17 @@ import {
3838import * as Errors from "../../common/errors" ;
3939import { Overlay2 } from "../overlay2/overlay2" ;
4040import { ResizeSensor } from "../resize-sensor/resizeSensor" ;
41- // eslint-disable-next-line import/no-cycle
42- import { Tooltip } from "../tooltip/tooltip" ;
4341
4442import { matchReferenceWidthModifier } from "./customModifiers" ;
4543import { POPOVER_ARROW_SVG_SIZE , PopoverArrow } from "./popoverArrow" ;
4644import { positionToPlacement } from "./popoverPlacementUtils" ;
45+ import { PopoverInteractionKind , type PopoverProps } from "./popoverProps" ;
4746import type {
4847 DefaultPopoverTargetHTMLProps ,
4948 PopoverClickTargetHandlers ,
5049 PopoverHoverTargetHandlers ,
51- PopoverSharedProps ,
5250} from "./popoverSharedProps" ;
5351import { getBasePlacement , getTransformOrigin } from "./popperUtils" ;
54- import type { PopupKind } from "./popupKind" ;
55-
56- export const PopoverInteractionKind = {
57- CLICK : "click" as const ,
58- CLICK_TARGET_ONLY : "click-target" as const ,
59- HOVER : "hover" as const ,
60- HOVER_TARGET_ONLY : "hover-target" as const ,
61- } ;
62- export type PopoverInteractionKind = ( typeof PopoverInteractionKind ) [ keyof typeof PopoverInteractionKind ] ;
63-
64- export interface PopoverProps < TProps extends DefaultPopoverTargetHTMLProps = DefaultPopoverTargetHTMLProps >
65- extends PopoverSharedProps < TProps > {
66- /**
67- * Whether the popover/tooltip should acquire application focus when it first opens.
68- *
69- * @default true for click interactions, false for hover interactions
70- */
71- autoFocus ?: boolean ;
72-
73- /** HTML props for the backdrop element. Can be combined with `backdropClassName`. */
74- backdropProps ?: React . HTMLProps < HTMLDivElement > ;
75-
76- /**
77- * The kind of interaction that triggers the display of the popover.
78- *
79- * @default "click"
80- */
81- interactionKind ?: PopoverInteractionKind ;
82-
83- /**
84- * The kind of popup displayed by the popover. Gets directly applied to the
85- * `aria-haspopup` attribute of the target element. This property is
86- * ignored if `interactionKind` is {@link PopoverInteractionKind.HOVER_TARGET_ONLY}.
87- *
88- * @default "menu" or undefined
89- */
90- popupKind ?: PopupKind ;
91-
92- /**
93- * Enables an invisible overlay beneath the popover that captures clicks and
94- * prevents interaction with the rest of the document until the popover is
95- * closed. This prop is only available when `interactionKind` is
96- * `PopoverInteractionKind.CLICK`. When popovers with backdrop are opened,
97- * they become focused.
98- *
99- * @default false
100- */
101- hasBackdrop ?: boolean ;
102-
103- /**
104- * Whether the application should return focus to the last active element in the
105- * document after this popover closes.
106- *
107- * This is automatically set (overridden) to:
108- * - `false` for hover interaction popovers
109- * - `true` when a popover closes due to an ESC keypress
110- *
111- * If you are attaching a popover _and_ a tooltip to the same target, you must take
112- * care to either disable this prop for the popover _or_ disable the tooltip's
113- * `openOnTargetFocus` prop.
114- *
115- * @default false
116- */
117- shouldReturnFocusOnClose ?: boolean ;
118-
119- /**
120- * Popper.js positioning strategy.
121- *
122- * @see https://popper.js.org/docs/v2/constructors/#strategy
123- * @default "absolute"
124- */
125- positioningStrategy ?: PositioningStrategy ;
126- }
12752
12853export interface PopoverState {
12954 hasDarkParent : boolean ;
@@ -421,7 +346,7 @@ export class Popover<
421346 ...childTargetProps ,
422347 className : classNames ( childTarget . props . className , targetModifierClasses ) ,
423348 // force disable single Tooltip child when popover is open
424- disabled : isOpen && Utils . isElementOfType ( childTarget , Tooltip ) ? true : childTarget . props . disabled ,
349+ disabled : isOpen && isElementTooltip ( childTarget ) ? true : childTarget . props . disabled ,
425350 tabIndex : childTarget . props . tabIndex ?? targetTabIndex ,
426351 } ) ;
427352 const wrappedTarget = createElement (
@@ -789,6 +714,10 @@ export class Popover<
789714 }
790715}
791716
717+ function isElementTooltip ( element : any ) : boolean {
718+ return element ?. type ?. displayName === `${ DISPLAYNAME_PREFIX } .Tooltip` ;
719+ }
720+
792721function isEscapeKeypressEvent ( e ?: Event ) {
793722 return e instanceof KeyboardEvent && e . key === "Escape" ;
794723}
0 commit comments