Skip to content

Commit 0a809ac

Browse files
authored
Toolbar - Context Menu height is incorrect on first open in React (T1322123) 🍒 (#32669)
1 parent 31bfe03 commit 0a809ac

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

packages/devextreme/js/__internal/ui/toolbar/internal/toolbar.menu.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,12 @@ export default class DropDownMenu extends Widget<DropDownMenuProperties> {
353353
activeStateEnabled: true,
354354
onItemRendered,
355355
_itemAttributes: { role: 'menuitem' },
356+
_onItemsRendered: (): void => {
357+
// T1322123
358+
if (this.option('templatesRenderAsynchronously')) {
359+
this._popup?._renderGeometry();
360+
}
361+
},
356362
});
357363
}
358364

packages/devextreme/testing/tests/DevExpress.ui.widgets/toolbar.menu.tests.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,41 @@ QUnit.module('render', moduleConfig, () => {
290290
assert.strictEqual(this.overflowMenu.$popupContent().closest($container).length, 1, 'Popover content located into desired container');
291291
});
292292

293+
QUnit.test('popup should have correct height after async item templates are rendered (T1322123)', function(assert) {
294+
const templateRenderingTimeout = 10;
295+
const itemHeight = 50;
296+
297+
this.instance.option({
298+
items: [1, 2, 3],
299+
templatesRenderAsynchronously: true,
300+
integrationOptions: {
301+
templates: {
302+
'item': {
303+
render({ model, container, onRendered }) {
304+
setTimeout(() => {
305+
const $item = $(`<div>${model}</div>`);
306+
$item.css('height', itemHeight);
307+
$item.appendTo(container);
308+
309+
onRendered();
310+
}, templateRenderingTimeout);
311+
}
312+
}
313+
}
314+
},
315+
});
316+
317+
this.overflowMenu.click();
318+
319+
this.clock.tick(templateRenderingTimeout);
320+
321+
const $overlayContent = this.overflowMenu.popup().$overlayContent();
322+
const overlayContentHeight = getOuterHeight($overlayContent);
323+
324+
assert.strictEqual(this.overflowMenu.$items().length, 3, 'all items are rendered');
325+
assert.strictEqual(overlayContentHeight, 197, 'popup height is updated');
326+
});
327+
293328
QUnit.test('popup should be placed into new container after changing the container option', function(assert) {
294329
const $container = $('#dropDownMenu');
295330

0 commit comments

Comments
 (0)