From d6b12d20ccd90fc3ba366b87359c20c3d5c1b47d Mon Sep 17 00:00:00 2001 From: Justin-ZS Date: Mon, 10 Mar 2025 18:45:45 +0800 Subject: [PATCH 1/2] fix(tooltip): Changing tooltip config doesn't refresh the displayed tooltip --- src/component/tooltip/TooltipView.ts | 17 ++- test/runTest/actions/__meta__.json | 1 + test/runTest/actions/tooltip-refresh.json | 1 + test/tooltip-refresh.html | 120 ++++++++++++++++++++++ 4 files changed, 134 insertions(+), 5 deletions(-) create mode 100644 test/runTest/actions/tooltip-refresh.json create mode 100644 test/tooltip-refresh.html diff --git a/src/component/tooltip/TooltipView.ts b/src/component/tooltip/TooltipView.ts index d5bf5d8f21..2a7e77d8cc 100644 --- a/src/component/tooltip/TooltipView.ts +++ b/src/component/tooltip/TooltipView.ts @@ -243,6 +243,11 @@ class TooltipView extends ComponentView { const api = this._api; const triggerOn = tooltipModel.get('triggerOn'); + if (tooltipModel.option.trigger !== 'axis') { + // _lastDataByCoordSys is used for axis tooltip. + this._lastDataByCoordSys = null; + } + // Try to keep the tooltip show when refreshing if (this._lastX != null && this._lastY != null @@ -365,11 +370,13 @@ class TooltipView extends ComponentView { else if (payload.x != null && payload.y != null) { // FIXME // should wrap dispatchAction like `axisPointer/globalListener` ? - api.dispatchAction({ - type: 'updateAxisPointer', - x: payload.x, - y: payload.y - }); + if (tooltipModel.option.trigger === 'axis') { + api.dispatchAction({ + type: 'updateAxisPointer', + x: payload.x, + y: payload.y + }); + } this._tryShow({ offsetX: payload.x, diff --git a/test/runTest/actions/__meta__.json b/test/runTest/actions/__meta__.json index 3a9a4d28cd..c6da30ca7c 100644 --- a/test/runTest/actions/__meta__.json +++ b/test/runTest/actions/__meta__.json @@ -202,6 +202,7 @@ "tooltip-domnode": 1, "tooltip-event": 1, "tooltip-link": 2, + "tooltip-refresh": 1, "tooltip-rich": 1, "tooltip-setOption": 2, "tooltip-valueFormatter": 3, diff --git a/test/runTest/actions/tooltip-refresh.json b/test/runTest/actions/tooltip-refresh.json new file mode 100644 index 0000000000..cddc6fab13 --- /dev/null +++ b/test/runTest/actions/tooltip-refresh.json @@ -0,0 +1 @@ +[{"name":"Action 1","ops":[{"type":"mousemove","time":454,"x":481,"y":259},{"type":"mousemove","time":654,"x":492,"y":263},{"type":"mousedown","time":717,"x":492,"y":263},{"type":"mouseup","time":823,"x":492,"y":263},{"time":824,"delay":2200,"type":"screenshot-auto"}],"scrollY":0,"scrollX":0,"timestamp":1737531200147}] \ No newline at end of file diff --git a/test/tooltip-refresh.html b/test/tooltip-refresh.html new file mode 100644 index 0000000000..9bc9e156a6 --- /dev/null +++ b/test/tooltip-refresh.html @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + From a578fe335ef313fc84d2300f935fda2b50204c21 Mon Sep 17 00:00:00 2001 From: Justin-ZS Date: Thu, 13 Mar 2025 17:29:24 +0800 Subject: [PATCH 2/2] fix: code review --- src/component/tooltip/TooltipView.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/component/tooltip/TooltipView.ts b/src/component/tooltip/TooltipView.ts index 2a7e77d8cc..db4face3e5 100644 --- a/src/component/tooltip/TooltipView.ts +++ b/src/component/tooltip/TooltipView.ts @@ -370,13 +370,11 @@ class TooltipView extends ComponentView { else if (payload.x != null && payload.y != null) { // FIXME // should wrap dispatchAction like `axisPointer/globalListener` ? - if (tooltipModel.option.trigger === 'axis') { - api.dispatchAction({ - type: 'updateAxisPointer', - x: payload.x, - y: payload.y - }); - } + api.dispatchAction({ + type: 'updateAxisPointer', + x: payload.x, + y: payload.y + }); this._tryShow({ offsetX: payload.x,