From 6c51b934f9a397ebf38c5588356962cf597e46bc Mon Sep 17 00:00:00 2001 From: Aasim Khan Date: Thu, 17 Mar 2022 14:11:15 -0700 Subject: [PATCH] Fixing clickable state of infobox not setting properly when initializing it. (#18763) * Fixing clickable state of infobox not set when initializing it. * Removing unnecessary calls to a method --- src/sql/base/browser/ui/infoBox/infoBox.ts | 35 ++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/sql/base/browser/ui/infoBox/infoBox.ts b/src/sql/base/browser/ui/infoBox/infoBox.ts index 99f29b6ff6..55c19dd8f6 100644 --- a/src/sql/base/browser/ui/infoBox/infoBox.ts +++ b/src/sql/base/browser/ui/infoBox/infoBox.ts @@ -68,6 +68,7 @@ export class InfoBox extends Disposable implements IThemable { this.isClickable = (options.isClickable === true); this.clickableButtonAriaLabel = options.clickableButtonAriaLabel; } + this.updateClickableState(); } public style(styles: IInfoBoxStyles): void { @@ -125,21 +126,7 @@ export class InfoBox extends Disposable implements IThemable { return; } this._isClickable = v; - if (this._isClickable) { - this._clickableIndicator.style.display = ''; - this._clickableIndicator.tabIndex = 0; - this._infoBoxElement.style.cursor = 'pointer'; - this._infoBoxElement.setAttribute('role', 'button'); - this._textElement.style.maxWidth = 'calc(100% - 75px)'; - this.registerClickListeners(); - } else { - this._clickableIndicator.style.display = 'none'; - this._clickableIndicator.tabIndex = -1; - this._infoBoxElement.style.cursor = 'default'; - this._infoBoxElement.removeAttribute('role'); - this._textElement.style.maxWidth = ''; - this.unregisterClickListeners(); - } + this.updateClickableState(); } private registerClickListeners() { @@ -193,4 +180,22 @@ export class InfoBox extends Disposable implements IThemable { this._infoBoxElement.style.backgroundColor = backgroundColor.toString(); } } + + private updateClickableState(): void { + if (this._isClickable) { + this._clickableIndicator.style.display = ''; + this._clickableIndicator.tabIndex = 0; + this._infoBoxElement.style.cursor = 'pointer'; + this._infoBoxElement.setAttribute('role', 'button'); + this._textElement.style.maxWidth = 'calc(100% - 75px)'; + this.registerClickListeners(); + } else { + this._clickableIndicator.style.display = 'none'; + this._clickableIndicator.tabIndex = -1; + this._infoBoxElement.style.cursor = 'default'; + this._infoBoxElement.removeAttribute('role'); + this._textElement.style.maxWidth = ''; + this.unregisterClickListeners(); + } + } }