-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: add a default min-height to grid (#7964)
* wip * use a constant row height * add tests * revert changes to dev page * update visual tests * add fallback if constructed stylesheets are not supported * add test * remove duplicate import * include scrollbar in measurement --------- Co-authored-by: Tomi Virkki <virkki@vaadin.com>
- Loading branch information
1 parent
17fe568
commit 1cc5372
Showing
10 changed files
with
170 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import '../theme/lumo/lit-all-imports.js'; | ||
import '../src/lit-all-imports.js'; | ||
import './min-height.common.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import '../vaadin-grid.js'; | ||
import './min-height.common.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import { expect } from '@vaadin/chai-plugins'; | ||
import { fixtureSync } from '@vaadin/testing-helpers'; | ||
import { flushGrid, infiniteDataProvider, nextResize } from './helpers.js'; | ||
|
||
describe('min-height', () => { | ||
const rowHeight = 36; | ||
|
||
let grid; | ||
|
||
function verifyMinHeight(withHeader = false, withFooter = false) { | ||
const height = grid.getBoundingClientRect().height; | ||
|
||
const headerHeight = grid.$.header.getBoundingClientRect().height; | ||
if (withHeader) { | ||
expect(headerHeight).to.be.above(0); | ||
} else { | ||
expect(headerHeight).to.equal(0); | ||
} | ||
|
||
const footerHeight = grid.$.footer.getBoundingClientRect().height; | ||
if (withFooter) { | ||
expect(footerHeight).to.be.above(0); | ||
} else { | ||
expect(footerHeight).to.equal(0); | ||
} | ||
|
||
const expectedHeight = rowHeight + headerHeight + footerHeight; | ||
expect(height).to.equal(expectedHeight); | ||
} | ||
|
||
beforeEach(async () => { | ||
grid = fixtureSync(` | ||
<vaadin-grid style="height: 0;"> | ||
<vaadin-grid-column></vaadin-grid-column> | ||
</vaadin-grid> | ||
`); | ||
flushGrid(grid); | ||
await nextResize(grid); | ||
}); | ||
|
||
describe('without header or footer', () => { | ||
it('should should have min-height of one row', () => { | ||
verifyMinHeight(); | ||
}); | ||
}); | ||
|
||
describe('with header', () => { | ||
beforeEach(async () => { | ||
grid.querySelector('vaadin-grid-column').header = 'Header'; | ||
flushGrid(grid); | ||
await nextResize(grid); | ||
}); | ||
|
||
it('should should have min-height of header and one row', () => { | ||
verifyMinHeight(true, false); | ||
}); | ||
}); | ||
|
||
describe('with footer', () => { | ||
beforeEach(async () => { | ||
grid.querySelector('vaadin-grid-column').footerRenderer = (root) => { | ||
root.textContent = 'Footer'; | ||
}; | ||
flushGrid(grid); | ||
await nextResize(grid); | ||
}); | ||
|
||
it('should should have min-height of footer and one row', () => { | ||
verifyMinHeight(false, true); | ||
}); | ||
}); | ||
|
||
describe('with header and footer', () => { | ||
beforeEach(async () => { | ||
grid.querySelector('vaadin-grid-column').header = 'Header'; | ||
grid.querySelector('vaadin-grid-column').footerRenderer = (root) => { | ||
root.textContent = 'Footer'; | ||
}; | ||
flushGrid(grid); | ||
await nextResize(grid); | ||
}); | ||
|
||
it('should should have min-height of header, footer and one row', () => { | ||
verifyMinHeight(true, true); | ||
}); | ||
}); | ||
|
||
describe('with data', () => { | ||
beforeEach(async () => { | ||
grid.querySelector('vaadin-grid-column').path = 'value'; | ||
grid.querySelector('vaadin-grid-column').header = null; | ||
grid.dataProvider = infiniteDataProvider; | ||
flushGrid(grid); | ||
await nextResize(grid); | ||
}); | ||
|
||
it('should should have min-height of one row', () => { | ||
verifyMinHeight(); | ||
}); | ||
}); | ||
|
||
describe('override', () => { | ||
beforeEach(() => { | ||
fixtureSync(` | ||
<style> | ||
vaadin-grid { | ||
min-height: 200px; | ||
} | ||
</style> | ||
`); | ||
}); | ||
|
||
it('should allow overriding min-height through stylesheet', () => { | ||
const height = grid.getBoundingClientRect().height; | ||
expect(height).to.equal(200); | ||
}); | ||
}); | ||
}); |
Binary file modified
BIN
+281 Bytes
(120%)
packages/grid/test/visual/lumo/screenshots/grid/baseline/ltr-header-footer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+260 Bytes
(110%)
packages/grid/test/visual/lumo/screenshots/grid/baseline/rtl-header-footer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+381 Bytes
(120%)
packages/grid/test/visual/material/screenshots/grid/baseline/ltr-header-footer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+244 Bytes
(120%)
packages/grid/test/visual/material/screenshots/grid/baseline/rtl-header-footer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.