From 49549ae2103d2dc9a29b590b33f1733638786651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E7=88=B1=E5=90=83=E7=99=BD=E8=90=9D?= =?UTF-8?q?=E5=8D=9C?= Date: Tue, 16 May 2023 15:19:39 +0800 Subject: [PATCH] fix: Use visible first (#42394) --- components/_util/placements.ts | 9 ++++++++- components/tooltip/index.tsx | 1 + package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/components/_util/placements.ts b/components/_util/placements.ts index 01cf938c4d..4a8792d68b 100644 --- a/components/_util/placements.ts +++ b/components/_util/placements.ts @@ -13,6 +13,7 @@ export interface PlacementsConfig { autoAdjustOverflow?: boolean | AdjustOverflow; offset: number; borderRadius: number; + visibleFirst?: boolean; } export function getOverflowOptions( @@ -141,7 +142,8 @@ const DisableAutoArrowList: Set = new Set([ ]); export default function getPlacements(config: PlacementsConfig) { - const { arrowWidth, autoAdjustOverflow, arrowPointAtCenter, offset, borderRadius } = config; + const { arrowWidth, autoAdjustOverflow, arrowPointAtCenter, offset, borderRadius, visibleFirst } = + config; const halfArrowWidth = arrowWidth / 2; const placementMap: BuildInPlacements = {}; @@ -220,6 +222,11 @@ export default function getPlacements(config: PlacementsConfig) { // Overflow placementInfo.overflow = getOverflowOptions(key, arrowOffset, arrowWidth, autoAdjustOverflow); + + // VisibleFirst + if (visibleFirst) { + placementInfo.htmlRegion = 'visibleFirst'; + } }); return placementMap; diff --git a/components/tooltip/index.tsx b/components/tooltip/index.tsx index ce65630db3..4b7432b32d 100644 --- a/components/tooltip/index.tsx +++ b/components/tooltip/index.tsx @@ -291,6 +291,7 @@ const Tooltip = React.forwardRef((props, ref) => { arrowWidth: mergedShowArrow ? token.sizePopupArrow : 0, borderRadius: token.borderRadius, offset: token.marginXXS, + visibleFirst: true, }) ); }, [arrowPointAtCenter, arrow, builtinPlacements, token]); diff --git a/package.json b/package.json index 1d894b2594..e2d94d31dd 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "@rc-component/color-picker": "~1.0.0", "@rc-component/mutate-observer": "^1.0.0", "@rc-component/tour": "~1.8.0", - "@rc-component/trigger": "^1.12.0", + "@rc-component/trigger": "^1.13.0", "classnames": "^2.2.6", "copy-to-clipboard": "^3.2.0", "dayjs": "^1.11.1",