Skip to content

Commit

Permalink
Fix elements overflowing the grid
Browse files Browse the repository at this point in the history
Flex items have a min-width set to `auto` as per the spec:
https://www.w3.org/TR/css-flexbox/#min-size-auto

This causes elements like `pre` to extend past the `Grid-cell` even when
overflow is set.

Setting `min-width` to `0` fixes this and gives a more expected
behaviour in that situation.

Bug example: http://codepen.io/simonsmith/pen/BKGKBo
More detail: http://weblog.west-wind.com/posts/2016/Feb/15/Flexbox-Containers-PRE-tags-and-managing-Overflow
  • Loading branch information
simonsmith committed May 3, 2016
1 parent 212b35f commit 87df2ff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/grid.css
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,14 @@
* utility or a component class that extends 'Grid'.
*
* 1. Set flex items to full width by default
* 2. Fix issue where elements with overflow extend past the
* `Grid-cell` container.
*/

.Grid-cell {
box-sizing: inherit;
flex: 0 0 100%; /* 1 */
min-width: 0; /* 2 */
}

/**
Expand Down
18 changes: 18 additions & 0 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
min-height: 100px;
}

pre {
overflow: auto;
white-space: pre;
word-wrap: normal;
}

.Test {
padding: 0 10px;
}
Expand Down Expand Up @@ -53,6 +59,18 @@ <h3 class="Test-it">removes inter-cell whitespace</h3>
</div>
</div>
</div>
<h3 class="Test-it">handles overflowing elements</h3>
<div class="Test-run">
<div class="Grid">
<div class="Grid-cell">
<div class="fixture-Box">
<pre>
This is some really long content that should be scrolled when the container is too small.
</pre>
</div>
</div>
</div>
</div>
<h3 class="Test-it">automatically wraps cells across multiple lines when they don't fit a single row</h3>
<div class="Test-run">
<div class="Grid">
Expand Down

0 comments on commit 87df2ff

Please sign in to comment.