Skip to content

Commit 02b452c

Browse files
List: fix animation on collapse group (T1282693) (DevExpress#29813)
1 parent f67214a commit 02b452c

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

packages/devextreme/js/__internal/ui/list/m_list.base.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,13 +793,17 @@ export class ListBase extends CollectionWidget<ListBaseProperties> {
793793

794794
let endHeight = 0;
795795

796-
if (startHeight === 0) {
796+
if (collapsed) {
797797
setHeight($groupBody, 'auto');
798798
endHeight = getOuterHeight($groupBody);
799799
}
800800

801801
$group.toggleClass(LIST_GROUP_COLLAPSED_CLASS, toggle);
802802

803+
if (fx.isAnimating($groupBody)) {
804+
fx.stop($groupBody, false);
805+
}
806+
803807
fx.animate($groupBody, {
804808
// @ts-expect-error
805809
type: 'custom',

packages/devextreme/testing/tests/DevExpress.ui.widgets/listParts/commonTests.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,34 @@ QUnit.module('collapsible groups', moduleSetup, () => {
361361
assert.ok(!$group.hasClass(LIST_GROUP_COLLAPSED_CLASS), 'collapsed class is not present');
362362
});
363363

364+
QUnit.test('group body should be correctly collapsed on fast multiple clicks on header (T1282693)', function(assert) {
365+
this.clock.restore();
366+
const done = assert.async();
367+
368+
const $element = this.element.dxList({
369+
items: [{ key: 'a', items: ['0'] }],
370+
grouped: true,
371+
collapsibleGroups: true
372+
});
373+
374+
const $group = $element.find('.' + LIST_GROUP_CLASS);
375+
const $groupBody = $group.find('.' + LIST_GROUP_BODY_CLASS);
376+
const $groupHeader = $element.find('.' + LIST_GROUP_HEADER_CLASS);
377+
378+
const animationDuration = 200;
379+
380+
for(let i = 0; i < 11; i++) {
381+
$groupHeader.trigger('dxclick');
382+
}
383+
384+
setTimeout(() => {
385+
assert.strictEqual($group.hasClass(LIST_GROUP_COLLAPSED_CLASS), true, 'collapsed class is present');
386+
assert.strictEqual($groupBody.height(), 0, 'group items are hidden');
387+
388+
done();
389+
}, 2 * animationDuration);
390+
});
391+
364392
const LIST_GROUP_HEADER_INDICATOR_CLASS = 'dx-list-group-header-indicator';
365393

366394
QUnit.test('group header collapsed indicator element', function(assert) {

0 commit comments

Comments
 (0)