Skip to content

Commit 7fa9cba

Browse files
author
Alan Fleming
committed
Simplify tooltips to work everywhere
1 parent 3e49c8e commit 7fa9cba

File tree

5 files changed

+4
-40
lines changed

5 files changed

+4
-40
lines changed

packages/base/src/widget.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -1101,18 +1101,14 @@ export class DOMWidgetView extends WidgetView {
11011101
}
11021102

11031103
updateTooltip(): void {
1104-
const title = this.tooltip;
1105-
if (!title) {
1106-
this.el.removeAttribute('title');
1107-
} else if (!this.model.get('description')) {
1104+
const title = this.model.get('tooltip') ?? this.model.get('description');
1105+
if (title) {
11081106
this.el.setAttribute('title', title);
1107+
} else {
1108+
this.el.removeAttribute('title');
11091109
}
11101110
}
11111111

1112-
get tooltip() {
1113-
return this.model.get('tooltip') ?? this.model.get('description');
1114-
}
1115-
11161112
/**
11171113
* Update the DOM classes applied to an element, default to this.el.
11181114
*/

packages/controls/src/widget_bool.ts

-8
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,6 @@ export class CheckboxView extends DescriptionView {
179179
}
180180
}
181181

182-
updateTooltip(): void {
183-
super.updateTooltip();
184-
if (!this.checkbox) return; // we might be constructing the parent
185-
const title = this.tooltip;
186-
this.checkbox.setAttribute('title', title);
187-
this.descriptionSpan.setAttribute('title', title);
188-
}
189-
190182
events(): { [e: string]: string } {
191183
return {
192184
'click input[type="checkbox"]': '_handle_click',

packages/controls/src/widget_description.ts

-6
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,6 @@ export class DescriptionView extends DOMWidgetView {
9797
}
9898
}
9999

100-
updateTooltip(): void {
101-
super.updateTooltip();
102-
if (!this.label) return;
103-
this.label.title = this.tooltip;
104-
}
105-
106100
label: HTMLLabelElement;
107101
}
108102

packages/controls/src/widget_selection.ts

-6
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,6 @@ export class SelectionView extends DescriptionView {
6767
}
6868
}
6969

70-
updateTooltip(): void {
71-
super.updateTooltip();
72-
if (!this.listbox) return; // we might be constructing the parent
73-
this.listbox.setAttribute('title', this.tooltip);
74-
}
75-
7670
listbox: HTMLSelectElement;
7771
}
7872

packages/controls/src/widget_string.ts

-12
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,6 @@ export class TextareaView extends StringView {
378378
}
379379
}
380380

381-
updateTooltip(): void {
382-
super.updateTooltip();
383-
if (!this.textbox) return; // we might be constructing the parent
384-
this.textbox.setAttribute('title', this.tooltip);
385-
}
386-
387381
events(): { [e: string]: string } {
388382
return {
389383
'keydown input': 'handleKeyDown',
@@ -500,12 +494,6 @@ export class TextView extends StringView {
500494
}
501495
}
502496

503-
updateTooltip(): void {
504-
super.updateTooltip();
505-
if (!this.textbox) return; // we might be constructing the parent
506-
this.textbox.setAttribute('title', this.tooltip);
507-
}
508-
509497
update(options?: any): void {
510498
/**
511499
* Update the contents of this view

0 commit comments

Comments
 (0)