Skip to content

Commit

Permalink
Merge pull request #18221 from jianghaoran116/fix-18111
Browse files Browse the repository at this point in the history
<fix>(tooltip): fix alwaysShowContent doesn't work after leaving the …
  • Loading branch information
Ovilia authored Mar 3, 2023
2 parents dbec96f + 19c3c9d commit 0e2954c
Show file tree
Hide file tree
Showing 4 changed files with 277 additions and 11 deletions.
6 changes: 5 additions & 1 deletion src/component/tooltip/TooltipHTMLContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ class TooltipHTMLContent {
private _enterable = true;
private _zr: ZRenderType;

private _alwaysShowContent: boolean = false;
private _hideTimeout: number;
/**
* Hide delay time
Expand Down Expand Up @@ -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') || '';

Expand Down Expand Up @@ -488,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
Expand Down
7 changes: 6 additions & 1 deletion src/component/tooltip/TooltipRichContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class TooltipRichContent {

private _hideTimeout: number;

private _alwaysShowContent: boolean = false;

private _enterable = true;

private _inContent: boolean;
Expand All @@ -56,6 +58,9 @@ class TooltipRichContent {
update(tooltipModel: Model<TooltipOption>) {
const alwaysShowContent = tooltipModel.get('alwaysShowContent');
alwaysShowContent && this._moveIfResized();

// update alwaysShowContent
this._alwaysShowContent = alwaysShowContent;
}

show() {
Expand Down Expand Up @@ -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
Expand Down
10 changes: 1 addition & 9 deletions src/component/tooltip/TooltipView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ class TooltipView extends ComponentView {

private _api: ExtensionAPI;

private _alwaysShowContent: boolean;

private _tooltipContent: TooltipHTMLContent | TooltipRichContent;

private _refreshUpdateTimeout: number;
Expand Down Expand Up @@ -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'));
Expand Down Expand Up @@ -396,7 +388,7 @@ class TooltipView extends ComponentView {
) {
const tooltipContent = this._tooltipContent;

if (!this._alwaysShowContent && this._tooltipModel) {
if (this._tooltipModel) {
tooltipContent.hideLater(this._tooltipModel.get('hideDelay'));
}

Expand Down
265 changes: 265 additions & 0 deletions test/tooltip-alwaysShowContent.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0e2954c

Please sign in to comment.