From ff53ce183900f290c7361690201f54eae5bf8b64 Mon Sep 17 00:00:00 2001 From: xile611 Date: Thu, 15 May 2025 17:29:55 +0800 Subject: [PATCH 1/2] fix: tooltip should hide when enterable, fix #3965, fix #3922 --- packages/vchart/src/component/tooltip/tooltip.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/vchart/src/component/tooltip/tooltip.ts b/packages/vchart/src/component/tooltip/tooltip.ts index 752cea45f4..d3a378aec7 100644 --- a/packages/vchart/src/component/tooltip/tooltip.ts +++ b/packages/vchart/src/component/tooltip/tooltip.ts @@ -70,7 +70,7 @@ export class Tooltip extends BaseComponent implements ITooltip { private _cacheInfo: TooltipInfo | undefined; private _cacheParams: BaseEventParams | undefined; private _cacheActiveType: TooltipActiveType | undefined; - private _cacheEnterableRect: { x: number; y: number; width: number; height: number }; + private _cacheEnterableRect: { width: number; height: number }; private _eventList: EventHandlerList = []; @@ -185,7 +185,7 @@ export class Tooltip extends BaseComponent implements ITooltip { const rect = container.getBoundingClientRect?.(); if (rect) { - this._cacheEnterableRect = { x: rect.x, y: rect.y, width: rect.width, height: rect.height }; + this._cacheEnterableRect = { width: rect.width, height: rect.height }; } if (this._outTimer) { clearTimeout(this._outTimer); @@ -207,6 +207,10 @@ export class Tooltip extends BaseComponent implements ITooltip { if (this._cacheEnterableRect) { const newRect = container.getBoundingClientRect?.(); + /** + * 这里需要比对width,height,是防止用户在进入到tooltip 的时候做了一些操作, + * 导致tooltip的尺寸发生变更,这种情况一般不需要隐藏tooltip + */ if ( newRect && Object.keys(this._cacheEnterableRect).every( @@ -599,6 +603,7 @@ export class Tooltip extends BaseComponent implements ITooltip { if (!this.tooltipHandler?.showTooltip) { return false; } + const result = showTooltip(datum, options, this); if (result !== 'none') { this._alwaysShow = !!options?.alwaysShow; @@ -611,6 +616,7 @@ export class Tooltip extends BaseComponent implements ITooltip { if (this._isReleased) { return false; } + const params: TooltipHandlerParams = { changePositionOnly: false, tooltip: this, From cb278c46838d7f7e7946bc57985b45e63608d231 Mon Sep 17 00:00:00 2001 From: xile611 Date: Thu, 15 May 2025 17:32:42 +0800 Subject: [PATCH 2/2] docs: update changlog of rush --- .../fix-tooltip-enterable-hide_2025-05-15-09-32.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 common/changes/@visactor/vchart/fix-tooltip-enterable-hide_2025-05-15-09-32.json diff --git a/common/changes/@visactor/vchart/fix-tooltip-enterable-hide_2025-05-15-09-32.json b/common/changes/@visactor/vchart/fix-tooltip-enterable-hide_2025-05-15-09-32.json new file mode 100644 index 0000000000..9fe6120bda --- /dev/null +++ b/common/changes/@visactor/vchart/fix-tooltip-enterable-hide_2025-05-15-09-32.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "fix: tooltip should hide when enterable, fix #3965, fix #3922\n\n", + "type": "none", + "packageName": "@visactor/vchart" + } + ], + "packageName": "@visactor/vchart", + "email": "dingling112@gmail.com" +} \ No newline at end of file