null
Created
March 30, 2021 06:36
-
-
Save telamonian/a1475279ed2586c02f172fecf11ea681 to your computer and use it in GitHub Desktop.
row height bug repro for `regular-table` that shows how having a "fat" row breaks the calculation of number of rows to render
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> | |
<style> | |
.fat-header { | |
display: inline-flex; | |
flex-direction: column; | |
height: 96px; | |
} | |
</style> | |
</head> | |
<body> | |
<regular-table id="regularTable"></regular-table> | |
<script>window.addEventListener("load", () => init())</script> | |
<script src="https://cdn.jsdelivr.net/npm/regular-table"></script> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/regular-table/dist/css/material.css"> | |
<script src="row_height_bug.js"></script> | |
</body> | |
</html> |
This file contains hidden or 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
const _DATA = [ | |
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], | |
["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O"], | |
Array.from(Array(15).keys()).map((value) => value % 2 === 0), | |
]; | |
const DATA = _DATA.map(x => Array.from({length: 1000}, () => x).flat()); | |
const FatHeader = () => { | |
const header = document.createElement('div'); | |
header.innerHTML = ['one', 'two'].map(x => { | |
return `<span>${x}</span>`; | |
}).join(''); | |
header.className = "fat-header"; | |
// return header; | |
return header.outerHTML; | |
} | |
function dataListener(x0, y0, x1, y1) { | |
return { | |
num_rows: DATA[0].length, | |
num_columns: DATA.length, | |
data: DATA.slice(x0, x1).map((col) => col.slice(y0, y1)), | |
// column_headers: [[FatHeader(), 'foo'], [FatHeader(), 'bar'], [FatHeader(), 'baz']], | |
// column_headers: [['foo'], ['bar'], ['baz']], | |
// column_headers: [[FatHeader()], [FatHeader()], [FatHeader()]], | |
column_headers: [['foo', FatHeader()], ['bar', FatHeader()], ['baz', FatHeader()]], | |
}; | |
} | |
function init() { | |
window.regularTable.setDataListener(dataListener); | |
window.regularTable.draw(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment