question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Text in a grid item does not wrap, despite default or explicit attributes

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Wrapping text in a Grid item should not force it to not wrap

Current Behavior

Grid item makes it unwrappable, as far as I can tell.

Steps to Reproduce (for bugs)

I realize I might be doing something stupid, as I’m a material n00b and the samples don’t really cover my case. See the codebox or inline code below. The text inside the Grid item does not wrap, but the other block of text wraps as expected. Adding wrap=“wrap” had no effect, as did adding Typography with implicit or explicit wrapping.

Edit new

import React from 'react'
import Grid from 'material-ui/Grid'

const Example = () => (
  <div>
    <Grid container>
      <Grid item>
        This is some text that should be wrapped. Lorem ipsum dolor sit amet,
        consectetur adipisicing elit. Fugit magnam omnis eius ad quam ipsam
        dolorum iure itaque placeat fugiat animi iusto, asperiores nam
        architecto sit suscipit voluptates voluptate minima! Lorem ipsum dolor
        sit amet, consectetur adipisicing elit. Non, sunt fuga, doloremque,
        praesentium quod nulla tempore delectus deserunt veritatis quae ducimus
        temporibus. Recusandae alias, numquam eaque repudiandae aperiam rem quo?
      </Grid>
      <hr />
      This is some text that is wrapped. Lorem ipsum dolor sit amet, consectetur
      adipisicing elit. Fugit magnam omnis eius ad quam ipsam dolorum iure
      itaque placeat fugiat animi iusto, asperiores nam architecto sit suscipit
      voluptates voluptate minima! Lorem ipsum dolor sit amet, consectetur
      adipisicing elit. Non, sunt fuga, doloremque, praesentium quod nulla
      tempore delectus deserunt veritatis quae ducimus temporibus. Recusandae
      alias, numquam eaque repudiandae aperiam rem quo?
    </Grid>
  </div>
)

export default Example

Context

Would like to lay out some text in a grid item, but it loses the wrap property.

Your Environment

Tech Version
Material-UI 1.0.0-beta.47
React 16.3.2
browser Chrome Version 66.0.3359.139 (Official Build) (64-bit)
etc

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ShaneMcXcommented, May 15, 2018

This isn’t the default for flexbox, which will wrap contained items. The reason this is happening is because Grid elements with the item attribute introduce a Grid-item-nn class that is setting “flex: 0 0 auto” (shorthand: “flex: none”). Flexbox default is “flex: 0 1 auto” (AKA “flex: initial”), which allows items to shrink. Likely either flex initial or flex auto (“flex: 1 1 auto”) would be preferable.

Is this an explicit design decision or a bug? Either way, documenting it would be useful.

0reactions
ShaneMcXcommented, May 21, 2018

Awesome. Thanks for merging!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Text in a grid item does not wrap, despite default or explicit ...
The reason this is happening is because Grid elements with the item attribute introduce a Grid-item-nn class that is setting "flex: 0 0...
Read more >
Can grid items wrap? - Stack Overflow
Columns and rows don't wrap. They append to the existing set of columns or rows. Hence, grid items in this layout won't wrap....
Read more >
grid-template-rows - CSS: Cascading Style Sheets | MDN
The grid-template-rows CSS property defines the line names and track sizing ... Is a keyword meaning that there is no explicit grid.
Read more >
grid-template-columns | CSS-Tricks
Using the none value means grid-template-columns generates no explicit grid tracks which, in turn, means that columns are implicitly generated ( ...
Read more >
CSS Grid Layout Module Level 1 - W3C
The grid has no explicit columns; instead columns are added as ... its own grid item, even though inter-element text does get wrapped...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found