From 050d5cf435ccb127df77ed6968bbd5abc59adc63 Mon Sep 17 00:00:00 2001 From: zengyue ye Date: Sat, 21 May 2022 17:37:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20tooltip=20=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9B=B4=E6=96=B0=E6=97=B6=EF=BC=8CdefaultItem=20?= =?UTF-8?q?=E4=B8=BA=20=E7=A9=BA=E7=9A=84=E6=8A=A5=E9=94=99.=20Closed=20#1?= =?UTF-8?q?487=20(#1488)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../f2/src/components/tooltip/withTooltip.tsx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/f2/src/components/tooltip/withTooltip.tsx b/packages/f2/src/components/tooltip/withTooltip.tsx index ef0610aa9..61d67ca46 100644 --- a/packages/f2/src/components/tooltip/withTooltip.tsx +++ b/packages/f2/src/components/tooltip/withTooltip.tsx @@ -82,10 +82,7 @@ export default (View) => { const { defaultItem: nextDefaultItem, coord: nextCoord } = nextProps; const { defaultItem: lastDefaultItem, coord: lastCoord } = this.props; // 默认元素或坐标有变动,均需重新渲染 - if ( - !equal(nextDefaultItem, lastDefaultItem) - || !equal(nextCoord, lastCoord) - ) { + if (!equal(nextDefaultItem, lastDefaultItem) || !equal(nextCoord, lastCoord)) { this._showByData(nextDefaultItem); } } @@ -93,12 +90,11 @@ export default (View) => { _initShow() { const { props } = this; const { defaultItem } = props; - if (defaultItem) { - this._showByData(defaultItem); - } + this._showByData(defaultItem); } _showByData(dataItem) { + if (!dataItem) return; const { props } = this; const { chart } = props; // 因为 tooltip 有可能在 geometry 之前,所以需要等 geometry render 完后再执行 @@ -112,10 +108,12 @@ export default (View) => { this.show(points[0], ev); }; _triggerOff = () => { - const { props: {alwaysShow = false} } = this; + const { + props: { alwaysShow = false }, + } = this; if (!alwaysShow) { this.hide(); - } + } }; _initEvent() { const { context, props } = this;