Skip to content

Commit 4a4d8af

Browse files
ContextMenu: fix flickers when adding more items asynchronously or during runtime (T1247739) (#30317)
1 parent 47b3deb commit 4a4d8af

File tree

4 files changed

+4
-59
lines changed

4 files changed

+4
-59
lines changed

packages/devextreme/js/__internal/ui/overlay/m_overlay.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ class Overlay<
136136

137137
_zIndex!: number;
138138

139-
_asyncShowTimeout?: ReturnType<typeof setTimeout> | null;
140-
141139
_actions?: any;
142140

143141
_isHidingActionCanceled?: boolean;
@@ -578,13 +576,7 @@ class Overlay<
578576
this._processShowingHidingCancel(showingArgs.cancel, applyShow, cancelShow);
579577
};
580578

581-
if (this.option('templatesRenderAsynchronously')) {
582-
this._stopShowTimer();
583-
// NOTE: T390360, T386038
584-
this._asyncShowTimeout = setTimeout(show);
585-
} else {
586-
show();
587-
}
579+
show();
588580
}
589581

590582
return this._showingDeferred.promise();
@@ -664,7 +656,6 @@ class Overlay<
664656
this._forceFocusLost();
665657
this._toggleShading(false);
666658
this._toggleSubscriptions(false);
667-
this._stopShowTimer();
668659
this._animateHiding();
669660
};
670661

@@ -1229,18 +1220,9 @@ class Overlay<
12291220
}
12301221

12311222
this._renderVisibility(false);
1232-
this._stopShowTimer();
12331223
this._cleanFocusState();
12341224
}
12351225

1236-
_stopShowTimer(): void {
1237-
if (this._asyncShowTimeout) {
1238-
clearTimeout(this._asyncShowTimeout);
1239-
}
1240-
1241-
this._asyncShowTimeout = null;
1242-
}
1243-
12441226
_dispose(): void {
12451227
// @ts-expect-error
12461228
fx.stop(this._$content, false);

packages/devextreme/testing/tests/DevExpress.ui.widgets/drawer.scenarios.tests.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,9 @@ configs.forEach(config => {
492492
templates: {
493493
template1: {
494494
render(data) {
495-
drawer.getOverlay()._viewPortChangeHandler();
495+
Promise.resolve().then(() => {
496+
drawer.getOverlay()._viewPortChangeHandler();
497+
});
496498
$(data.container).append($(drawerTesters[config.position].template()));
497499
data.onRendered();
498500
}

packages/devextreme/testing/tests/DevExpress.ui.widgets/loadPanel.tests.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -270,26 +270,6 @@ QUnit.module('init', {
270270
assert.equal($content.find(MESSAGE_SELECTOR).text(), 'Test Loading Message');
271271
});
272272

273-
QUnit.test('load panel created with templatesRenderAsynchronously option should be shown with delay', function(assert) {
274-
const clock = sinon.useFakeTimers();
275-
try {
276-
const onShowingSpy = sinon.spy();
277-
278-
const instance = $('#loadPanel').dxLoadPanel({
279-
templatesRenderAsynchronously: true,
280-
visible: true,
281-
onShowing: onShowingSpy
282-
}).dxLoadPanel('instance');
283-
284-
assert.strictEqual(instance.option('templatesRenderAsynchronously'), true, 'templatesRenderAsynchronously option can be reassigned (T896267)');
285-
assert.strictEqual(onShowingSpy.called, false);
286-
clock.tick(10);
287-
assert.strictEqual(onShowingSpy.called, true);
288-
} finally {
289-
clock.restore();
290-
}
291-
});
292-
293273
QUnit.test('shows on init if loading option is true', function(assert) {
294274
$('#loadPanel').dxLoadPanel({ message: 'Test Loading Message', visible: true });
295275
assert.ok($('#loadPanel').is(':visible'));

packages/devextreme/testing/tests/DevExpress.ui.widgets/overlay.tests.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -204,25 +204,6 @@ testModule('render', moduleConfig, () => {
204204
}).remove();
205205
});
206206

207-
test('overlay created with templatesRenderAsynchronously option should be shown with delay', function(assert) {
208-
const clock = sinon.useFakeTimers();
209-
try {
210-
const onShowingSpy = sinon.spy();
211-
212-
$('#overlay').dxOverlay({
213-
templatesRenderAsynchronously: true,
214-
visible: true,
215-
onShowing: onShowingSpy
216-
});
217-
218-
assert.strictEqual(onShowingSpy.called, false);
219-
clock.tick(10);
220-
assert.strictEqual(onShowingSpy.called, true);
221-
} finally {
222-
clock.restore();
223-
}
224-
});
225-
226207
test('overlay should be positioned correctly after async template is rendered (T1114344)', function(assert) {
227208
// NOTE: React 18 renders templates asynchronously. It cannot be changed in our react wrappers.
228209

0 commit comments

Comments
 (0)