+ {safeHoverPolygons.length > 0 && (
+
+ )}
+
{
+ if (!nextOpen) {
+ setPolygons([]);
+ }
+ }}
+ popup={
+ setPolygons([])}>
+
Safe hover popup
+
+ Move through the gap to reach me.
+
+
+ }
+ >
+
+
+
+ The popup is offset upward, leaving a blank hover gap.
+
+
+ );
+};
+
+export default SafeHoverDemo;
diff --git a/src/Popup/Arrow.tsx b/src/Popup/Arrow.tsx
index 1ab8239e..508ef817 100644
--- a/src/Popup/Arrow.tsx
+++ b/src/Popup/Arrow.tsx
@@ -4,7 +4,7 @@ import type { AlignType, ArrowPos, ArrowTypeOuter } from '../interface';
export interface ArrowProps {
prefixCls: string;
- align: AlignType;
+ align?: AlignType;
arrow: ArrowTypeOuter;
arrowPos: ArrowPos;
}
diff --git a/src/hooks/useOffsetStyle.ts b/src/hooks/useOffsetStyle.ts
index 3c590041..75c2dc2e 100644
--- a/src/hooks/useOffsetStyle.ts
+++ b/src/hooks/useOffsetStyle.ts
@@ -28,8 +28,8 @@ export default function useOffsetStyle(
const { points } = align;
const dynamicInset =
align.dynamicInset || (align as any)._experimental?.dynamicInset;
- const alignRight = dynamicInset && points[0][1] === 'r';
- const alignBottom = dynamicInset && points[0][0] === 'b';
+ const alignRight = dynamicInset && points?.[0][1] === 'r';
+ const alignBottom = dynamicInset && points?.[0][0] === 'b';
if (alignRight) {
offsetStyle.right = offsetR;
diff --git a/src/index.tsx b/src/index.tsx
index bb5fb838..eb9f7f4f 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -13,7 +13,8 @@ import {
useLayoutEffect,
} from '@rc-component/util';
import * as React from 'react';
-import Popup, { type MobileConfig } from './Popup';
+import Popup from './Popup';
+import type { MobileConfig } from './Popup';
import type { TriggerContextProps } from './context';
import TriggerContext, { UniqueContext } from './context';
import useAction from './hooks/useAction';
@@ -22,7 +23,8 @@ import useDelay from './hooks/useDelay';
import useWatch from './hooks/useWatch';
import useWinClick from './hooks/useWinClick';
import type { PortalProps } from '@rc-component/portal';
-
+import { isPointInSafeHoverArea } from './util/safeHover';
+import type { SafeHoverPoint } from './util/safeHover';
import type {
ActionType,
AlignType,
@@ -30,7 +32,7 @@ import type {
ArrowTypeOuter,
BuildInPlacements,
} from './interface';
-import { getAlignPopupClassName } from './util';
+import { clamp, getAlignPopupClassName } from './util';
export type {
ActionType,
@@ -421,7 +423,122 @@ export function generateTrigger(
}, delay);
};
- function onEsc({ top }: Parameters