Skip to content

Commit

Permalink
Fix for native and custom hover over view titles (#206408)
Browse files Browse the repository at this point in the history
  • Loading branch information
benibenj authored Feb 28, 2024
1 parent d4a6faf commit 6504145
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/vs/workbench/browser/parts/views/viewPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ export abstract class ViewPane extends Pane implements IView {
private readonly showActions: ViewPaneShowActions;
private headerContainer?: HTMLElement;
private titleContainer?: HTMLElement;
private titleContainerHover?: ICustomHover;
private titleDescriptionContainer?: HTMLElement;
private titleDescriptionContainerHover?: ICustomHover;
private iconContainer?: HTMLElement;
private iconContainerHover?: ICustomHover;
protected twistiesContainer?: HTMLElement;
Expand Down Expand Up @@ -523,7 +525,7 @@ export abstract class ViewPane extends Pane implements IView {

const calculatedTitle = this.calculateTitle(title);
this.titleContainer = append(container, $('h3.title', {}, calculatedTitle));
setupCustomHover(getDefaultHoverDelegate('mouse'), this.titleContainer, calculatedTitle);
this.titleContainerHover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this.titleContainer, calculatedTitle));

if (this._titleDescription) {
this.setTitleDescription(this._titleDescription);
Expand All @@ -537,7 +539,7 @@ export abstract class ViewPane extends Pane implements IView {
const calculatedTitle = this.calculateTitle(title);
if (this.titleContainer) {
this.titleContainer.textContent = calculatedTitle;
this.titleContainer.setAttribute('title', calculatedTitle);
this.titleContainerHover?.update(calculatedTitle);
}

if (this.iconContainer) {
Expand All @@ -552,10 +554,11 @@ export abstract class ViewPane extends Pane implements IView {
private setTitleDescription(description: string | undefined) {
if (this.titleDescriptionContainer) {
this.titleDescriptionContainer.textContent = description ?? '';
this.titleDescriptionContainer.setAttribute('title', description ?? '');
this.titleDescriptionContainerHover?.update(description ?? '');
}
else if (description && this.titleContainer) {
this.titleDescriptionContainer = after(this.titleContainer, $('span.description', { title: description }, description));
this.titleDescriptionContainer = after(this.titleContainer, $('span.description', {}, description));
this.titleDescriptionContainerHover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this.titleDescriptionContainer, description));
}
}

Expand Down

0 comments on commit 6504145

Please sign in to comment.