-
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] Fix Table sizing when shown in flex parent #1479
Changes from all commits
f260119
ef46d67
c1cef0e
b2be1fe
f1d50c7
77c3408
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 |
---|---|---|
|
@@ -12,6 +12,11 @@ $table-quadrant-z-index-top-left: $table-quadrant-z-index-left + 1; | |
// overflow within their parents; it should be large enough to hide a scrollbar of typical width. | ||
$table-quadrant-scroll-container-overflow: 20px; | ||
|
||
.bp-table-quadrant-stack { | ||
display: flex; | ||
height: 100%; | ||
} | ||
|
||
.bp-table-quadrant { | ||
position: absolute; | ||
top: 0; | ||
|
@@ -26,7 +31,7 @@ $table-quadrant-scroll-container-overflow: 20px; | |
|
||
.bp-table-quadrant-scroll-container { | ||
@include force-hardware-acceleration(); | ||
position: absolute; | ||
position: relative; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
|
@@ -51,9 +56,22 @@ $table-quadrant-scroll-container-overflow: 20px; | |
} | ||
|
||
.bp-table-quadrant-main { | ||
right: 0; | ||
bottom: 0; | ||
// use `relative` to ensure the table can size itself according to the MAIN quadrant's contents alone. | ||
// other quadrants should remain `absolute` to ensure they're taken out of the document flow. | ||
position: relative; | ||
top: auto; | ||
left: auto; | ||
z-index: $table-quadrant-z-index-main; | ||
// the MAIN quadrant should fill the whole table so that ghost cells will be visible if enabled | ||
width: 100%; | ||
height: 100%; | ||
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.
<div>
<div style="height: 100%">everything is cool</div>
<div>what now?</div>
</div> this should be okay since we control the siblings of this div, but just something to keep an eye on. 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. Yep, I was cognizant of this. We're good as far as I can tell. Every other sibling is |
||
|
||
.bp-table-quadrant-scroll-container { | ||
// the MAIN quadrant's scroll bars should be visible and should be flush with the right and | ||
// bottom edges of the table. | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
.bp-table-cell-client { | ||
background: $white; | ||
|
@@ -75,7 +93,11 @@ $table-quadrant-scroll-container-overflow: 20px; | |
z-index: $table-quadrant-z-index-left; | ||
|
||
.bp-table-quadrant-scroll-container { | ||
position: absolute; | ||
top: 0; | ||
right: -$table-quadrant-scroll-container-overflow; | ||
bottom: 0; | ||
height: auto; | ||
overflow-x: hidden; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -256,6 +256,10 @@ describe("<Table>", () => { | |
}); | ||
|
||
describe("Quadrants", () => { | ||
// constrain the container to a smaller size to force scrolling | ||
const CONTAINER_HEIGHT = 500; | ||
const CONTAINER_WIDTH = 500; | ||
|
||
const NUM_ROWS = 5; | ||
const NUM_COLUMNS = 5; | ||
const NUM_FROZEN_ROWS = 1; | ||
|
@@ -562,13 +566,15 @@ describe("<Table>", () => { | |
document.body.appendChild(containerElement); | ||
|
||
const tableComponent = ReactDOM.render( | ||
<Table | ||
numRows={LARGE_NUM_ROWS} | ||
numFrozenColumns={NUM_FROZEN_COLUMNS} | ||
numFrozenRows={NUM_FROZEN_ROWS} | ||
> | ||
{renderColumns({}, LARGE_NUM_COLUMNS)} | ||
</Table>, | ||
<div style={{ height: CONTAINER_HEIGHT, width: CONTAINER_WIDTH }}> | ||
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. so, what happens if users DON'T put the table in an explicitly sized div? can we never use normal flow? 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. 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, excellent. |
||
<Table | ||
numRows={LARGE_NUM_ROWS} | ||
numFrozenColumns={NUM_FROZEN_COLUMNS} | ||
numFrozenRows={NUM_FROZEN_ROWS} | ||
> | ||
{renderColumns({}, LARGE_NUM_COLUMNS)} | ||
</Table> | ||
</div>, | ||
containerElement, | ||
) as Table; | ||
|
||
|
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.
👍 this is usually my go-to solution for cutting my components out of the layout flow