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.

fxLayoutGap grid can conflict with parent gap and causes inconsistent behavior on screen resize

See original GitHub issue

Bug Report

What is the expected behavior?

The negative margin (gutter) should be applied on the fxLayoutGap="8px grid" element at all times.

What is the current behavior?

When a page loads for the first time the negative margin on the host element isn’t applied until the screen hits a media query break point.

What are the steps to reproduce?

I wasn’t able to reproduce this on Stackblitz probably because of the way it renders the live view might be triggering the fix. Here’s how it looks on my machine: resize

The div surrounding the buttons has a gap grid, but if you inspect it, there’s no style on it until you shrink the page enough to hit a break. after that it correctly has the 0 -8px -8px 0 margin on it even if you return to the original size.

Here’s the code that causes this for me: (buttons have to go in another div or else it screws them up with the gap margins, but it works fine on a tags with the mat-button style ¯\_(ツ)_/¯ )

<div fxLayoutGap="8px grid" fxLayout="row wrap">
      <div>
        <button mat-raised-button class="btn-space" color="primary"
          (click)="newBha()">New BHA</button>
      </div>
      <div>
        <button mat-raised-button class="btn-space" color="primary"
          (click)="copyBha()">Copy This BHA</button>
      </div>
      <div>
        <button mat-raised-button class="btn-space" color="primary"
          (click)="deleteBha()">Delete BHA</button>
      </div>
      <a color="primary">
        <mat-icon>insert_drive_file</mat-icon>
        BHA Report
      </a>
      <a color="primary">
        <mat-icon>insert_drive_file</mat-icon>
        Strap Sheets
      </a>
</div>

Which versions of Angular, Material, OS, TypeScript, browsers are affected?


Angular CLI: 7.2.1
Node: 11.2.0
OS: win32 x64
Angular: 7.2.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.12.1
@angular-devkit/build-angular     0.12.1
@angular-devkit/build-optimizer   0.12.1
@angular-devkit/build-webpack     0.12.1
@angular-devkit/core              7.2.1
@angular-devkit/schematics        7.2.1
@angular/cdk                      7.2.1
@angular/cli                      7.2.1
@angular/flex-layout              7.0.0-beta.23
@angular/material                 7.2.1
@ngtools/webpack                  7.2.1
@schematics/angular               7.2.1
@schematics/update                0.12.1
rxjs                              6.3.3
typescript                        3.2.2
webpack                           4.23.1

Is there anything else we should know?

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
rfuhrercommented, Jan 17, 2019

Yeah it’s not an incredible scenario to say “Space out these things, and one of these things contains a bunch of things i want to wrap if there’s no room”. But creating this ticket gave me a deeper understanding of how the gaps work. So the outer gap is adding margins to all children, the inner gap grid is adding margins to itself, which means conflict.

So as usual, the solution is even more divs 😃

<div fxLayout="column" fxLayoutGap="10px">
  <div> <!-- gets the 10px margin-->
    <div fxLayoutGap="50px grid" fxLayout="row wrap"> <!-- gets the -50px margin -->
0reactions
angular-automatic-lock-bot[bot]commented, Feb 3, 2022

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular flex-layout - fxLayoutGap causes annoying gap at end ...
For anyone looking for the answer to this problem, you need to add grid to fxLayoutGap.
Read more >
Angular UI/Material Design Flashcards by uday A - Brainscape
Responsive layouts in Material Design adapt to any possible screen size. ... that unlike the standard gap functionality, fxLayoutGap with the grid keyword ......
Read more >
fxLayoutGap API in Angular flex layout
fxLayoutGap is used to specify gap between flex children items inside flex container. fxLayoutGap is an optional API. fxLayoutGap directive should be added...
Read more >
2021年02月_weixin_39682944的博客_CSDN博客
localhost:3333 doesn't open. 2021-01-12. fxLayoutGap grid can conflict with parent gap and causes inconsistent behavior on screen resize. 2021-01-12 ...
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