Skip to content

Commit

Permalink
fix: 修复 tooltip 数据更新时,defaultItem 为 空的报错. Closed #1487 (#1488)
Browse files Browse the repository at this point in the history
  • Loading branch information
zengyue committed May 21, 2022
1 parent b92695a commit 050d5cf
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions packages/f2/src/components/tooltip/withTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,19 @@ 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);
}
}

_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 完后再执行
Expand All @@ -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;
Expand Down

0 comments on commit 050d5cf

Please sign in to comment.