diff --git a/packages/base/src/widget.ts b/packages/base/src/widget.ts index 46c6b0d9c7..bcd7d64f7a 100644 --- a/packages/base/src/widget.ts +++ b/packages/base/src/widget.ts @@ -1101,18 +1101,14 @@ export class DOMWidgetView extends WidgetView { } updateTooltip(): void { - const title = this.tooltip; - if (!title) { - this.el.removeAttribute('title'); - } else if (!this.model.get('description')) { + const title = this.model.get('tooltip') ?? this.model.get('description'); + if (title) { this.el.setAttribute('title', title); + } else { + this.el.removeAttribute('title'); } } - get tooltip() { - return this.model.get('tooltip') ?? this.model.get('description'); - } - /** * Update the DOM classes applied to an element, default to this.el. */ diff --git a/packages/controls/src/widget_bool.ts b/packages/controls/src/widget_bool.ts index bb7e0ee72a..8f2a67b521 100644 --- a/packages/controls/src/widget_bool.ts +++ b/packages/controls/src/widget_bool.ts @@ -179,14 +179,6 @@ export class CheckboxView extends DescriptionView { } } - updateTooltip(): void { - super.updateTooltip(); - if (!this.checkbox) return; // we might be constructing the parent - const title = this.tooltip; - this.checkbox.setAttribute('title', title); - this.descriptionSpan.setAttribute('title', title); - } - events(): { [e: string]: string } { return { 'click input[type="checkbox"]': '_handle_click', diff --git a/packages/controls/src/widget_description.ts b/packages/controls/src/widget_description.ts index 67aec82c32..fba21c7422 100644 --- a/packages/controls/src/widget_description.ts +++ b/packages/controls/src/widget_description.ts @@ -97,12 +97,6 @@ export class DescriptionView extends DOMWidgetView { } } - updateTooltip(): void { - super.updateTooltip(); - if (!this.label) return; - this.label.title = this.tooltip; - } - label: HTMLLabelElement; } diff --git a/packages/controls/src/widget_selection.ts b/packages/controls/src/widget_selection.ts index 8269b61fbf..050723c9c3 100644 --- a/packages/controls/src/widget_selection.ts +++ b/packages/controls/src/widget_selection.ts @@ -67,12 +67,6 @@ export class SelectionView extends DescriptionView { } } - updateTooltip(): void { - super.updateTooltip(); - if (!this.listbox) return; // we might be constructing the parent - this.listbox.setAttribute('title', this.tooltip); - } - listbox: HTMLSelectElement; } diff --git a/packages/controls/src/widget_string.ts b/packages/controls/src/widget_string.ts index 3c708398d8..bf00a3f34b 100644 --- a/packages/controls/src/widget_string.ts +++ b/packages/controls/src/widget_string.ts @@ -378,12 +378,6 @@ export class TextareaView extends StringView { } } - updateTooltip(): void { - super.updateTooltip(); - if (!this.textbox) return; // we might be constructing the parent - this.textbox.setAttribute('title', this.tooltip); - } - events(): { [e: string]: string } { return { 'keydown input': 'handleKeyDown', @@ -500,12 +494,6 @@ export class TextView extends StringView { } } - updateTooltip(): void { - super.updateTooltip(); - if (!this.textbox) return; // we might be constructing the parent - this.textbox.setAttribute('title', this.tooltip); - } - update(options?: any): void { /** * Update the contents of this view