RFC: 为 Dropdown、Menu 等弹层类组件提供 Safe Hover Polygon 交互能力 #57778
li-jia-nan
started this conversation in
RFCs
Replies: 2 comments · 1 reply
-
|
安全三角形是不是可以考虑直接作为组件的默认行为,不用开 api 吧 🤔 |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
很赞的交互设计。 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
背景
Ant Design 中一些弹层类组件会通过 hover 触发展示,例如:
在实际使用中,如果触发元素和弹层之间存在间距,用户从触发元素移动到弹层内容时,鼠标会短暂离开触发元素区域,导致弹层提前关闭:
Kapture.2026-04-25.at.15.33.48.mp4
这在弹层内容包含可交互元素时尤其明显
目前可以通过 mouseLeaveDelay 缓解:
但 delay 只能延迟关闭,不能判断用户是否真的在移动向弹层。
更理想的行为是:
这类能力可以参考 Floating UI 的 safePolygon 思路:
safe-polygon.mp4
提案
为部分弹层组件增加 safeHover 属性。
API 设计
组件 Props:
支持范围
建议第一阶段优先支持:
Popover、Tooltip 可以支持,但不是主要场景,因为它通常只展示简单说明,不承载复杂交互内容。
行为说明
safeHover 只在 trigger 包含 hover 时生效。
以下场景不生效:
如果同时配置了
mouseLeaveDelay,两者可以共存:可以理解为:
默认关闭
safeHover: false原因:
开发者可以在需要时手动开启。
风险:
Beta Was this translation helpful? Give feedback.
All reactions