From 6af586f691cd3e2cc2c32c9b7fc4a49857075d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E6=B5=A9=E7=84=B6?= Date: Wed, 1 Feb 2023 18:54:31 +0800 Subject: [PATCH 1/4] (tooltip): fix alwaysShowContent doesn't work after leaving the tooltip . close #18111 --- src/component/tooltip/TooltipHTMLContent.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/component/tooltip/TooltipHTMLContent.ts b/src/component/tooltip/TooltipHTMLContent.ts index 02496857b0..3dcfc3761c 100644 --- a/src/component/tooltip/TooltipHTMLContent.ts +++ b/src/component/tooltip/TooltipHTMLContent.ts @@ -262,6 +262,7 @@ class TooltipHTMLContent { private _enterable = true; private _zr: ZRenderType; + private _alwaysShowContent: boolean = false; private _hideTimeout: number; /** * Hide delay time @@ -336,7 +337,7 @@ class TooltipHTMLContent { self._inContent = false; if (self._enterable) { - if (self._show) { + if (self._show && !self._alwaysShowContent) { self.hideLater(self._hideDelay); } } @@ -360,6 +361,9 @@ class TooltipHTMLContent { const alwaysShowContent = tooltipModel.get('alwaysShowContent'); alwaysShowContent && this._moveIfResized(); + // update alwaysShowContent + this._alwaysShowContent = alwaysShowContent; + // update className this.el.className = tooltipModel.get('className') || ''; From 376e45580a995d67291f1e9c5865e979e4cd509c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E6=B5=A9=E7=84=B6?= Date: Thu, 2 Feb 2023 16:21:16 +0800 Subject: [PATCH 2/4] (tooltip): fix alwaysShowContent doesn't work after leaving the tooltip . close #18111 --- src/component/tooltip/TooltipHTMLContent.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/component/tooltip/TooltipHTMLContent.ts b/src/component/tooltip/TooltipHTMLContent.ts index 3dcfc3761c..b326acd091 100644 --- a/src/component/tooltip/TooltipHTMLContent.ts +++ b/src/component/tooltip/TooltipHTMLContent.ts @@ -337,7 +337,7 @@ class TooltipHTMLContent { self._inContent = false; if (self._enterable) { - if (self._show && !self._alwaysShowContent) { + if (self._show) { self.hideLater(self._hideDelay); } } @@ -492,7 +492,7 @@ class TooltipHTMLContent { } hideLater(time?: number) { - if (this._show && !(this._inContent && this._enterable)) { + if (this._show && !(this._inContent && this._enterable) && !this._alwaysShowContent) { if (time) { this._hideDelay = time; // Set show false to avoid invoke hideLater multiple times From ac64e3f1c0a009c404e0f33454a9e38964426537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E6=B5=A9=E7=84=B6?= Date: Thu, 2 Feb 2023 17:23:42 +0800 Subject: [PATCH 3/4] (tooltip): fix alwaysShowContent doesn't work after leaving the tooltip . close #18111 --- src/component/tooltip/TooltipRichContent.ts | 7 +- src/component/tooltip/TooltipView.ts | 6 +- test/tooltip-alwaysShowContent.html | 265 ++++++++++++++++++++ 3 files changed, 274 insertions(+), 4 deletions(-) create mode 100644 test/tooltip-alwaysShowContent.html diff --git a/src/component/tooltip/TooltipRichContent.ts b/src/component/tooltip/TooltipRichContent.ts index c78da5ef49..d8f038dcbf 100644 --- a/src/component/tooltip/TooltipRichContent.ts +++ b/src/component/tooltip/TooltipRichContent.ts @@ -37,6 +37,8 @@ class TooltipRichContent { private _hideTimeout: number; + private _alwaysShowContent: boolean = false; + private _enterable = true; private _inContent: boolean; @@ -56,6 +58,9 @@ class TooltipRichContent { update(tooltipModel: Model) { const alwaysShowContent = tooltipModel.get('alwaysShowContent'); alwaysShowContent && this._moveIfResized(); + + // update alwaysShowContent + this._alwaysShowContent = alwaysShowContent; } show() { @@ -190,7 +195,7 @@ class TooltipRichContent { } hideLater(time?: number) { - if (this._show && !(this._inContent && this._enterable)) { + if (this._show && !(this._inContent && this._enterable) && !this._alwaysShowContent) { if (time) { this._hideDelay = time; // Set show false to avoid invoke hideLater multiple times diff --git a/src/component/tooltip/TooltipView.ts b/src/component/tooltip/TooltipView.ts index e64c2d19d4..e9865f3f64 100644 --- a/src/component/tooltip/TooltipView.ts +++ b/src/component/tooltip/TooltipView.ts @@ -147,7 +147,7 @@ class TooltipView extends ComponentView { private _api: ExtensionAPI; - private _alwaysShowContent: boolean; + // private _alwaysShowContent: boolean; private _tooltipContent: TooltipHTMLContent | TooltipRichContent; @@ -200,7 +200,7 @@ class TooltipView extends ComponentView { * @private * @type {boolean} */ - this._alwaysShowContent = tooltipModel.get('alwaysShowContent'); + // this._alwaysShowContent = tooltipModel.get('alwaysShowContent'); const tooltipContent = this._tooltipContent; tooltipContent.update(tooltipModel); @@ -396,7 +396,7 @@ class TooltipView extends ComponentView { ) { const tooltipContent = this._tooltipContent; - if (!this._alwaysShowContent && this._tooltipModel) { + if (this._tooltipModel) { tooltipContent.hideLater(this._tooltipModel.get('hideDelay')); } diff --git a/test/tooltip-alwaysShowContent.html b/test/tooltip-alwaysShowContent.html new file mode 100644 index 0000000000..67a1ea3f1b --- /dev/null +++ b/test/tooltip-alwaysShowContent.html @@ -0,0 +1,265 @@ + + + + + + + + + + + + + + + +

alwaysShowContent: true

+
+ + +

alwaysShowContent: true, renderMode: "richText", triggerOn: 'click',

+
+ + + + + + + + From 19c3c9d453eb900ed2ae4e7d7933e27466b1b72f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E6=B5=A9=E7=84=B6?= Date: Tue, 21 Feb 2023 10:43:46 +0800 Subject: [PATCH 4/4] (tooltip): fix alwaysShowContent doesn't work after leaving the tooltip . close #18111 --- src/component/tooltip/TooltipView.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/component/tooltip/TooltipView.ts b/src/component/tooltip/TooltipView.ts index e9865f3f64..82a222cb1d 100644 --- a/src/component/tooltip/TooltipView.ts +++ b/src/component/tooltip/TooltipView.ts @@ -147,8 +147,6 @@ class TooltipView extends ComponentView { private _api: ExtensionAPI; - // private _alwaysShowContent: boolean; - private _tooltipContent: TooltipHTMLContent | TooltipRichContent; private _refreshUpdateTimeout: number; @@ -196,12 +194,6 @@ class TooltipView extends ComponentView { this._api = api; - /** - * @private - * @type {boolean} - */ - // this._alwaysShowContent = tooltipModel.get('alwaysShowContent'); - const tooltipContent = this._tooltipContent; tooltipContent.update(tooltipModel); tooltipContent.setEnterable(tooltipModel.get('enterable'));