Skip to content

Commit bda5853

Browse files
authored
Accordion: allow validation messages to overflow in opened items (T1327641) (#33517)
1 parent 0e362fd commit bda5853

3 files changed

Lines changed: 110 additions & 0 deletions

File tree

-9.83 KB
Loading

packages/devextreme/js/__internal/ui/accordion.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ class Accordion extends CollectionWidgetLiveUpdate<AccordionProperties, Item, Co
345345
finalItemHeight = getOuterHeight($title);
346346
}
347347

348+
$item.css('overflow', '');
349+
$item.children(`.${ACCORDION_ITEM_BODY_CLASS}`).css('overflow', '');
350+
348351
return this._animateItem($item, startItemHeight, finalItemHeight, skipAnimation, !!itemHeight);
349352
}
350353

@@ -385,6 +388,11 @@ class Accordion extends CollectionWidgetLiveUpdate<AccordionProperties, Item, Co
385388
$element.css('height', '');
386389
}
387390

391+
if ($element.hasClass(ACCORDION_ITEM_OPENED_CLASS)) {
392+
$element.css('overflow', 'visible');
393+
$element.children(`.${ACCORDION_ITEM_BODY_CLASS}`).css('overflow', 'visible');
394+
}
395+
388396
$element
389397
.not(`.${ACCORDION_ITEM_OPENED_CLASS}`)
390398
.addClass(ACCORDION_ITEM_CLOSED_CLASS);

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

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,3 +1610,105 @@ QUnit.module('optionChanged', moduleSetup, () => {
16101610
});
16111611
});
16121612

1613+
QUnit.module('item overflow behavior (T1327641)', moduleSetup, () => {
1614+
QUnit.test('opened item has overflow:visible', function(assert) {
1615+
this.$element.dxAccordion({
1616+
items: this.items,
1617+
selectedIndex: 0,
1618+
});
1619+
1620+
const $item = this.$element.find(`.${ACCORDION_ITEM_CLASS}`).eq(0);
1621+
const $body = $item.children(`.${ACCORDION_ITEM_BODY_CLASS}`);
1622+
1623+
assert.strictEqual($item.css('overflow'), 'visible', 'item has overflow:visible');
1624+
assert.strictEqual($body.css('overflow'), 'visible', 'item body has overflow:visible');
1625+
});
1626+
1627+
QUnit.test('closed item has no overflow:visible style', function(assert) {
1628+
this.$element.dxAccordion({
1629+
items: this.items,
1630+
selectedIndex: 0,
1631+
});
1632+
1633+
const $closedItem = this.$element.find(`.${ACCORDION_ITEM_CLASS}`).eq(1);
1634+
1635+
assert.strictEqual($closedItem.css('overflow'), 'hidden', 'closed item has no overflow:visible');
1636+
});
1637+
1638+
QUnit.test('only opened items get overflow:visible in multiple mode', function(assert) {
1639+
this.$element.dxAccordion({
1640+
items: this.items,
1641+
selectedIndex: 0,
1642+
multiple: true,
1643+
collapsible: true,
1644+
});
1645+
1646+
const $items = this.$element.find(`.${ACCORDION_ITEM_CLASS}`);
1647+
1648+
assert.strictEqual($items.eq(0).css('overflow'), 'visible', 'opened item has overflow:visible');
1649+
assert.strictEqual($items.eq(1).css('overflow'), 'hidden', 'closed item has no overflow:visible');
1650+
assert.strictEqual($items.eq(2).css('overflow'), 'hidden', 'closed item has no overflow:visible');
1651+
});
1652+
1653+
QUnit.test('overflow resets when item starts closing', function(assert) {
1654+
const instance = this.$element.dxAccordion({
1655+
items: this.items,
1656+
selectedIndex: 0,
1657+
collapsible: true,
1658+
}).dxAccordion('instance');
1659+
1660+
const $item = this.$element.find(`.${ACCORDION_ITEM_CLASS}`).eq(0);
1661+
1662+
assert.strictEqual($item.css('overflow'), 'visible', 'item has overflow:visible before closing');
1663+
1664+
instance.collapseItem(0);
1665+
1666+
assert.strictEqual($item.css('overflow'), 'hidden', 'overflow reset when closing starts');
1667+
});
1668+
1669+
QUnit.test('overflow:visible is set after opening animation completes', function(assert) {
1670+
fx.off = false;
1671+
1672+
try {
1673+
this.$element.dxAccordion({
1674+
items: this.items,
1675+
selectedIndex: -1,
1676+
collapsible: true,
1677+
animationDuration: 100,
1678+
});
1679+
1680+
const instance = this.$element.dxAccordion('instance');
1681+
const $item = this.$element.find(`.${ACCORDION_ITEM_CLASS}`).eq(0);
1682+
1683+
instance.expandItem(0);
1684+
1685+
const $body = $item.children(`.${ACCORDION_ITEM_BODY_CLASS}`);
1686+
1687+
assert.strictEqual($item.css('overflow'), 'hidden', 'overflow is not yet visible during animation');
1688+
1689+
this.clock.tick(100);
1690+
1691+
assert.strictEqual($item.css('overflow'), 'visible', 'item has overflow:visible after animation');
1692+
assert.strictEqual($body.css('overflow'), 'visible', 'item body has overflow:visible after animation');
1693+
} finally {
1694+
fx.off = true;
1695+
}
1696+
});
1697+
1698+
QUnit.test('overflow:visible is restored when item is re-opened after closing', function(assert) {
1699+
const instance = this.$element.dxAccordion({
1700+
items: this.items,
1701+
selectedIndex: 0,
1702+
collapsible: true,
1703+
}).dxAccordion('instance');
1704+
1705+
instance.collapseItem(0);
1706+
1707+
const $item = this.$element.find(`.${ACCORDION_ITEM_CLASS}`).eq(0);
1708+
assert.strictEqual($item.css('overflow'), 'hidden', 'overflow is reset after close');
1709+
1710+
instance.expandItem(0);
1711+
assert.strictEqual($item.css('overflow'), 'visible', 'overflow:visible restored after re-open');
1712+
});
1713+
});
1714+

0 commit comments

Comments
 (0)