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.

fxflex wrongly assigning max/min width

See original GitHub issue

Bug, feature request, or proposal:

There seems to be a bug with fxflex where max/min width is set even though grow/shrink is specified.

What is the expected behavior?

Using fxflex value of 1 1 700px, no max width / min width should be applied. The docs say:

flex-shrink: defines how much a flexbox item should shrink if there is not enough space available.

as well as

flex-grow: defines how much a flexbox item should grow (proportional to the others) if there’s space available. The flex-grow value overrides the width.

Note that is explicitly states that flex-grow will override the width.

So if flex-shrink and flex-grow are specified, the element should be able to shrink if there is not enough space left and grow if there is leftover space.

What is the current behavior?

Max/Min width will be applied to elements even if they have shrink/grow enabled. This seems to be the contrary of what will happen if you use standard css flexbox with the same values (there, the elements will grow/shrink correctly).

Funnily enough, the max width will not be applied if you wrap the pixel values into calc (e.g. 1 1 calc(700px)). The min width, however, will still be applied.

Simple example (see stackblitz link below):

<div fxFlex="1 1 150px" class="sec2" >
    second-section
</div>
<div fxFlex="2 1 300px" class="sec3">
    third-section
</div>

What are the steps to reproduce?

See this stackblitz for the above example

Here a stackblitz showing that max width will not be applied if pixel values are wrapped in calc

What is the use-case or motivation for changing an existing behavior?

Either im bad at reading docs or this is broken / the docs are wrong.

I originally wanted to have two divs in a row, where one has a maximum width of 300px and the other takes up the remaining space, but when div two shrinks below 700px, both divs start to shrink. Since this did not work, i now switched to simply using a basis of 0 and chosing the appropriate grow/shrink for both divs.

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

Happens in stackblitz (Angular 5) as well as in my private project (Angular 6), so: Angular Version: 6.0.1 / 5.2.9 Material Version: 6.0.1 / 5.2.4 flex-layout Version: 6.0.0-beta.15 / 5.0.0-beta.13 OS: Windows 10 64 bit Typescript: 2.7.2 / whatever stackblitz example uses Browser: Chrome 66 64 bit

Is there anything else we should know?

If I just overread something in the docs or this is a known issue or intended behaviour, i’m sorry. I also hope this is not a duplicate. I looked through open issues and googled a bit and could not find something. I only found this SO thread and there it is also said that the docs seem to be wrong.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
tmtroncommented, May 24, 2019

Now that we’ve introduced StyleBuilders, you can change the algorithm if you want! So I’m closing this issue with the suggestion of building your own algorithm and using that instead.

@CaerusKaru : Is there an example for a custom style builder that works as expected by this bugreport?

1reaction
adamdportcommented, Jun 5, 2018

I agree with you, the max/min width thing doesn’t make sense to me. You can read some discussion of it in #438 and #689.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Flexbox: How To Set Max Width To A Div - ADocLib
The fxFlex directive should mimic as close as possible the CSS flex property with the fxflex wrongly assigning max/min width #748. You can...
Read more >
Angular Flexbox: how to set max width of a div - Stack Overflow
The solution is to use the "shrink" and "grow" value of the FxFlex tag. Grow: How to grow the element Shrink: How to...
Read more >
Angular Flex Layout: The Masquerade | by Aleix Suau - Medium
fxFlex flex-basis fixes the main-axis size of the item making it unresponsive (it adds a min-width and max-width when direction=row, and min-height and...
Read more >
Building a Simple Responsive App with Angular Flex Layout
You can set the width to 100% by just adding fxFlex or by assigning it a value of 100% i.e. fxFlex="100%" . The...
Read more >
CSS Width, Height and Overflow | max-width & min ... - YouTube
CSS Width, Height and Overflow | max- width & min- width Properties ExplainedSECTIONS: (00:00) - INTRO(00:15) - Creating a Div Element ...
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