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.

[Layout Grid] Include an ability for mdc-layout-grid to look at the container width instead of the window width to determine if breakpoint needs to be changed

See original GitHub issue

I’ve noticed that mdc-layout-grid looks at the window width when determines which breakpoint to use. It means that if a component with mdc-layout-grid is part of some other container the breakpoint is not switched until the width of the browser window (more precisely the viewport) crosses the breakpoint width boundary. This leads to the mdc-layout-grid not changing layout even though the container width that it is enclosed in is less than a breakpoint target width. This demonstrates what I mean.

<table>
        <tr>
          <td style="min-width: 220px;">left</td>
          <td>
            <div class="mdc-layout-grid">
              <div class="mdc-layout-grid__inner">
                <div
                  class="mdc-layout-grid__cell--span-2-desktop mdc-layout-grid__cell--span-4-tablet mdc-layout-grid__cell--span-4-phone"
                  style="height: 150px; background-color: red;"
                ></div>
                <div
                  class="mdc-layout-grid__cell--span-2-desktop mdc-layout-grid__cell--span-4-tablet mdc-layout-grid__cell--span-4-phone"
                  style="height: 150px; background-color: red;"
                ></div>
                <div
                  class="mdc-layout-grid__cell--span-2-desktop mdc-layout-grid__cell--span-4-tablet mdc-layout-grid__cell--span-4-phone"
                  style="height: 150px; background-color: red;"
                ></div>
                <div
                  class="mdc-layout-grid__cell--span-2-desktop mdc-layout-grid__cell--span-4-tablet mdc-layout-grid__cell--span-4-phone"
                  style="height: 150px; background-color: red;"
                ></div>
                <div
                  class="mdc-layout-grid__cell--span-2-desktop mdc-layout-grid__cell--span-4-tablet mdc-layout-grid__cell--span-4-phone"
                  style="height: 150px; background-color: red;"
                ></div>
                <div
                  class="mdc-layout-grid__cell--span-2-desktop mdc-layout-grid__cell--span-4-tablet mdc-layout-grid__cell--span-4-phone"
                  style="height: 150px; background-color: red;"
                ></div>
              </div>
            </div>
          </td>
          <td style="min-width: 220px;">
            right
          </td>
        </tr>
      </table>

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
peterlitvakcommented, Feb 8, 2020

Thank you!

0reactions
allan-chencommented, Feb 8, 2020

Hi, Thanks for reaching out. This component was implemented according to Material Design guidelines to account for viewport widths only. As Simon suggested, for your use case, it might be best to use a solution that polyfills element queries.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Responsive layout grid - Material Design
The Material Design responsive layout grid adapts to screen size and orientation. This UI guidance includes a flexible grid that ensures consistency across ......
Read more >
Responsive layout grid - Hussain Almoamen
The Material Design responsive layout grid adapts to screen size and ... layout can use breakpoints to determine if the layout needs to...
Read more >
material/layout-grid
A grid is a container that consists of a group of cells. Grid can define its own max-width or designate its columns to...
Read more >
Change the size of the gutter of an MDC layout grid using a ...
Cross-post from discussion on MDC Web's GitHub issue tracker: The reason the mixin doesn't appear to do anything is because it sets the ......
Read more >
Responsive Components: a Solution to the Container ...
Container queries is a proposal that would allow web developers to style DOM elements based on the size of a containing element rather...
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