Skip to content

Commit 0e2954c

Browse files
authored
Merge pull request #18221 from jianghaoran116/fix-18111
<fix>(tooltip): fix alwaysShowContent doesn't work after leaving the …
2 parents dbec96f + 19c3c9d commit 0e2954c

File tree

4 files changed

+277
-11
lines changed

4 files changed

+277
-11
lines changed

src/component/tooltip/TooltipHTMLContent.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ class TooltipHTMLContent {
262262
private _enterable = true;
263263
private _zr: ZRenderType;
264264

265+
private _alwaysShowContent: boolean = false;
265266
private _hideTimeout: number;
266267
/**
267268
* Hide delay time
@@ -360,6 +361,9 @@ class TooltipHTMLContent {
360361
const alwaysShowContent = tooltipModel.get('alwaysShowContent');
361362
alwaysShowContent && this._moveIfResized();
362363

364+
// update alwaysShowContent
365+
this._alwaysShowContent = alwaysShowContent;
366+
363367
// update className
364368
this.el.className = tooltipModel.get('className') || '';
365369

@@ -488,7 +492,7 @@ class TooltipHTMLContent {
488492
}
489493

490494
hideLater(time?: number) {
491-
if (this._show && !(this._inContent && this._enterable)) {
495+
if (this._show && !(this._inContent && this._enterable) && !this._alwaysShowContent) {
492496
if (time) {
493497
this._hideDelay = time;
494498
// Set show false to avoid invoke hideLater multiple times

src/component/tooltip/TooltipRichContent.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class TooltipRichContent {
3737

3838
private _hideTimeout: number;
3939

40+
private _alwaysShowContent: boolean = false;
41+
4042
private _enterable = true;
4143

4244
private _inContent: boolean;
@@ -56,6 +58,9 @@ class TooltipRichContent {
5658
update(tooltipModel: Model<TooltipOption>) {
5759
const alwaysShowContent = tooltipModel.get('alwaysShowContent');
5860
alwaysShowContent && this._moveIfResized();
61+
62+
// update alwaysShowContent
63+
this._alwaysShowContent = alwaysShowContent;
5964
}
6065

6166
show() {
@@ -190,7 +195,7 @@ class TooltipRichContent {
190195
}
191196

192197
hideLater(time?: number) {
193-
if (this._show && !(this._inContent && this._enterable)) {
198+
if (this._show && !(this._inContent && this._enterable) && !this._alwaysShowContent) {
194199
if (time) {
195200
this._hideDelay = time;
196201
// Set show false to avoid invoke hideLater multiple times

src/component/tooltip/TooltipView.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ class TooltipView extends ComponentView {
147147

148148
private _api: ExtensionAPI;
149149

150-
private _alwaysShowContent: boolean;
151-
152150
private _tooltipContent: TooltipHTMLContent | TooltipRichContent;
153151

154152
private _refreshUpdateTimeout: number;
@@ -196,12 +194,6 @@ class TooltipView extends ComponentView {
196194

197195
this._api = api;
198196

199-
/**
200-
* @private
201-
* @type {boolean}
202-
*/
203-
this._alwaysShowContent = tooltipModel.get('alwaysShowContent');
204-
205197
const tooltipContent = this._tooltipContent;
206198
tooltipContent.update(tooltipModel);
207199
tooltipContent.setEnterable(tooltipModel.get('enterable'));
@@ -396,7 +388,7 @@ class TooltipView extends ComponentView {
396388
) {
397389
const tooltipContent = this._tooltipContent;
398390

399-
if (!this._alwaysShowContent && this._tooltipModel) {
391+
if (this._tooltipModel) {
400392
tooltipContent.hideLater(this._tooltipModel.get('hideDelay'));
401393
}
402394

test/tooltip-alwaysShowContent.html

Lines changed: 265 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)