Skip to content

Commit

Permalink
fix: column span in section
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivirkki committed Aug 22, 2024
1 parent 2be720f commit b260a6c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/dashboard/src/vaadin-dashboard-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ class DashboardSection extends ControllerMixin(ElementMixin(PolylitMixin(LitElem
display: none !important;
}
::slotted(*) {
--_vaadin-dashboard-item-column: span
min(
var(--vaadin-dashboard-item-colspan, 1),
var(--_vaadin-dashboard-effective-col-count, var(--_vaadin-dashboard-col-count))
);
grid-column: var(--_vaadin-dashboard-item-column);
}
header {
display: flex;
grid-column: 1 / -1;
Expand Down
14 changes: 13 additions & 1 deletion packages/dashboard/test/dashboard-layout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ describe('dashboard layout', () => {
<div id="item-2">Section item 2</div>
<div id="item-3">Section item 3</div>
</vaadin-dashboard-section>
`);
`);
dashboard.appendChild(section);
await nextFrame();
childElements = [...dashboard.querySelectorAll('div')];
Expand Down Expand Up @@ -371,6 +371,18 @@ describe('dashboard layout', () => {
]);
});

it('should span multiple columns inside a section', async () => {
dashboard.style.width = `${columnWidth * 3}px`;
setColspan(childElements[2], 2);
await nextFrame();

/* prettier-ignore */
expectLayout(dashboard, [
[0, 1, null],
[2, 2, 3],
]);
});

describe('gap', () => {
it('should have a default gap', () => {
// Clear the gap used in the tests
Expand Down

0 comments on commit b260a6c

Please sign in to comment.