Skip to content

Commit 0333085

Browse files
Trial panel improvements (DevExpress#30175)
Co-authored-by: Vasily Strelyaev <[email protected]>
1 parent dbabc62 commit 0333085

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

packages/devextreme/js/__internal/core/license/trial_panel.client.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const SafeHTMLElement = isClient()
2020
? HTMLElement
2121
// eslint-disable-next-line @stylistic/max-len
2222
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-extraneous-class
23-
: class {} as any as typeof HTMLElement;
23+
: class { } as any as typeof HTMLElement;
2424

2525
const DATA_PERMANENT_ATTRIBUTE = 'data-permanent';
2626
const componentNames = {
@@ -94,12 +94,12 @@ function createImportantStyles(defaultStyles: StylesMap, customStyles?: StylesMa
9494
class DxLicense extends SafeHTMLElement {
9595
public static customStyles: CustomTrialPanelStyles | undefined = undefined;
9696

97+
static closed = false;
98+
9799
private _observer: MutationObserver | null = null;
98100

99101
private _inReassign = false;
100102

101-
private _hidden = false;
102-
103103
private readonly _spanStyles: string;
104104

105105
private readonly _linkStyles: string;
@@ -174,7 +174,7 @@ class DxLicense extends SafeHTMLElement {
174174
button.appendChild(svg);
175175

176176
button.onclick = (): void => {
177-
this._hidden = true;
177+
DxLicense.closed = true;
178178
this.style.cssText = createImportantStyles({
179179
display: 'none',
180180
});
@@ -208,7 +208,7 @@ class DxLicense extends SafeHTMLElement {
208208
this._reassignComponent();
209209
if (!this._observer) {
210210
this._observer = new MutationObserver(() => {
211-
if (this._hidden) {
211+
if (DxLicense.closed) {
212212
this._observer?.disconnect();
213213
return;
214214
}
@@ -228,12 +228,21 @@ class DxLicense extends SafeHTMLElement {
228228
}
229229

230230
public disconnectedCallback(): void {
231-
setTimeout(() => {
231+
if (DxLicense.closed) {
232+
return;
233+
}
234+
235+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
236+
Promise.resolve().then(() => {
237+
if (!document) {
238+
return;
239+
}
240+
232241
const licensePanel = document.getElementsByTagName(componentNames.panel);
233242
if (!licensePanel.length) {
234243
document.body.prepend(this);
235244
}
236-
}, 100);
245+
});
237246
}
238247
}
239248
class DxLicenseTrigger extends SafeHTMLElement {
@@ -243,7 +252,7 @@ class DxLicenseTrigger extends SafeHTMLElement {
243252
});
244253

245254
const licensePanel = document.getElementsByTagName(componentNames.panel);
246-
if (!licensePanel.length) {
255+
if (!licensePanel.length && !DxLicense.closed) {
247256
const license = document.createElement(componentNames.panel);
248257

249258
license.setAttribute(
@@ -261,7 +270,7 @@ class DxLicenseTrigger extends SafeHTMLElement {
261270
this.getAttribute(attributeNames.licensingDoc) as string,
262271
);
263272

264-
license.setAttribute(DATA_PERMANENT_ATTRIBUTE, 'true');
273+
license.setAttribute(DATA_PERMANENT_ATTRIBUTE, '');
265274

266275
document.body.prepend(license);
267276
}

0 commit comments

Comments
 (0)