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
This commit is contained in:
Aasim Khan
2022-03-17 14:11:15 -07:00
committed by GitHub
parent 9f2940e8f8
commit 6c51b934f9

View File

@@ -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();
}
}
}