Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make dashboard scrollable #7662

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/dashboard/src/vaadin-dashboard-layout-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const DashboardLayoutMixin = (superClass) =>
static get styles() {
return css`
:host {
display: grid;
/* Default min and max column widths */
--_vaadin-dashboard-default-col-min-width: 25rem;
--_vaadin-dashboard-default-col-max-width: 1fr;
Expand All @@ -36,6 +35,9 @@ export const DashboardLayoutMixin = (superClass) =>
var(--_vaadin-dashboard-default-col-max-width)
);

display: grid;
overflow: auto;

grid-template-columns: repeat(
auto-fill,
minmax(var(--_vaadin-dashboard-col-min-width), var(--_vaadin-dashboard-col-max-width))
Expand All @@ -44,6 +46,10 @@ export const DashboardLayoutMixin = (superClass) =>
gap: var(--vaadin-dashboard-gap, 1rem);
}

:host([hidden]) {
display: none !important;
}

::slotted(*) {
grid-column: span min(var(--vaadin-dashboard-item-colspan, 1), var(--_vaadin-dashboard-item-max-colspan));
}
Expand Down
16 changes: 16 additions & 0 deletions packages/dashboard/test/dashboard-layout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ describe('dashboard layout', () => {
]);
});

it('should not display when hidden', () => {
expect(dashboard.offsetHeight).to.be.above(0);
dashboard.hidden = true;
expect(dashboard.offsetHeight).to.eql(0);
});

it('should be responsive', () => {
// Narrow down the component to fit one column
dashboard.style.width = `${columnWidth}px`;
Expand All @@ -91,6 +97,16 @@ describe('dashboard layout', () => {
]);
});

it('should scroll when content overflows', () => {
dashboard.style.width = `${columnWidth}px`;
const rowHeight = Math.ceil(getRowHeights(dashboard)[0]);
dashboard.style.height = `${rowHeight}px`;
expect(dashboard.scrollTop).to.eql(0);

dashboard.scrollTop = 1;
expect(dashboard.scrollTop).to.eql(1);
});

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