-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[Table] Add resizeRowsByTallestCells to handle multi-column resize #1075
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,22 +103,42 @@ describe("<Table>", () => { | |
rowHeaders.forEach((rowHeader) => expectCellLoading(rowHeader, CellType.ROW_HEADER)); | ||
}); | ||
|
||
it("Gets and sets the tallest cell height in the table", () => { | ||
const renderCell = () => <Cell wrapText={true}>my cell value with lots and lots of words</Cell>; | ||
it("Gets and sets the tallest cell by columns correctly", () => { | ||
const DEFAULT_RESIZE_HEIGHT = 30; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
const MAX_HEIGHT = 40; | ||
const renderCellLong = () => <Cell wrapText={true}>my cell value with lots and lots of words</Cell>; | ||
const renderCellShort = () => <Cell wrapText={false}>short value</Cell>; | ||
|
||
let table: Table; | ||
|
||
const saveTable = (t: Table) => table = t; | ||
|
||
harness.mount( | ||
<Table ref={saveTable} numRows={4}> | ||
<Column name="Column0" renderCell={renderCell} /> | ||
<Column name="Column1" renderCell={renderCell} /> | ||
<Column name="Column0" renderCell={renderCellLong} /> | ||
<Column name="Column1" renderCell={renderCellShort} /> | ||
</Table>, | ||
); | ||
|
||
// Resize by first column | ||
table.resizeRowsByTallestCell(0); | ||
expect(table.state.rowHeights[0]).to.equal(40); | ||
expect(table.state.rowHeights[0]).to.equal(MAX_HEIGHT); | ||
|
||
// Resize by second column | ||
table.resizeRowsByTallestCell(1); | ||
expect(table.state.rowHeights[0]).to.equal(DEFAULT_RESIZE_HEIGHT); | ||
|
||
// Resize by both columns | ||
table.resizeRowsByTallestCell([0, 1]); | ||
expect(table.state.rowHeights[0]).to.equal(MAX_HEIGHT); | ||
|
||
// Resize by second column via array | ||
table.resizeRowsByTallestCell([1]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you remove brackets here to test non-array syntax? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh nvm i see the lines above now 👍 |
||
expect(table.state.rowHeights[0]).to.equal(DEFAULT_RESIZE_HEIGHT); | ||
|
||
// Resize by visible columns | ||
table.resizeRowsByTallestCell(); | ||
expect(table.state.rowHeights[0]).to.equal(MAX_HEIGHT); | ||
}); | ||
|
||
it("Selects all on click of upper-left corner", () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake: do we need to clarify "tallest visible cell" in this sentence too, or is it implicitly clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the "in view" satisfies that constraint, but to y'all. Happy to make the change if it's more clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change to
default to using the tallest visible cell from all columns in view
? That way it doesn't really get any longer.