Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fxFlex is not work well with NgStyle.lt-md and layout change #700

Closed
Teamop opened this issue Apr 6, 2018 · 3 comments · Fixed by #771
Closed

fxFlex is not work well with NgStyle.lt-md and layout change #700

Teamop opened this issue Apr 6, 2018 · 3 comments · Fixed by #771
Assignees
Labels
bug flexbox has pr A PR has been created to address this issue P0 Critical issue that needs to be resolved immediately

Comments

@Teamop
Copy link
Contributor

Teamop commented Apr 6, 2018

Bug, feature request, or proposal:

Set fxFlex="5 1 auto" with [ngStyle.lt-md]="{'width.px': 90}", but in the final html, got style: flex: 1 1 0%

What is the expected behavior?

the flex should be the same in the html

What is the current behavior?

got style: flex: 1 1 0%

What are the steps to reproduce?

Providing a StackBlitz (or similar) is the best way to get the team to see your issue.
https://stackblitz.com/edit/angular-material-flex-layout-seed-76pec8, check the checkbox, then inspect the displayed span item next to it(items selected)

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

the unexpected style change

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

Angular 5.2.9
Angular material 5.2.4
Typescript 2.6.2

Is there anything else we should know?

After some research, checking the checkbox triggers the layout change, so _onLayoutChange() is invoked in flex , then set ngStyle to flex: 1 1 0%, then for NgStyle.lt-md, the code styles = extendObject({}, this._base.inputMap['ngStyle'], styles); (https://github.com/angular/flex-layout/blob/master/src/lib/extended/style/style.ts#L179) merges this style to override the original style

@Teamop Teamop changed the title fxFlex is not work well with NgStyle.lt-md fxFlex is not work well with NgStyle.lt-md and layout change Apr 6, 2018
@CaerusKaru CaerusKaru self-assigned this Apr 6, 2018
@CaerusKaru CaerusKaru added bug flexbox P0 Critical issue that needs to be resolved immediately labels Apr 6, 2018
@CaerusKaru CaerusKaru added this to the v6.0.0-beta.15 milestone Apr 6, 2018
@CaerusKaru
Copy link
Member

This is definitely an issue, and a puzzling one. As you pointed out, this is caused by how our wrapper for the NgStyle directive is merging styles. At some point, the default fxFlex value is inserted, and the ngStyle value is completely ignored. My suggested workaround in the meantime while we track this down is to have a wrapper div with the fxFlex and then an inner div with the ngStyle, if that works.

@Teamop
Copy link
Contributor Author

Teamop commented Apr 9, 2018

@CaerusKaru Currently, I just use CSS flex to replace fxFlex as a workaround

Teamop added a commit to Teamop/flex-layout that referenced this issue May 7, 2018
Teamop added a commit to Teamop/flex-layout that referenced this issue May 7, 2018
@CaerusKaru CaerusKaru added the has pr A PR has been created to address this issue label Jun 7, 2018
CaerusKaru added a commit that referenced this issue Jun 11, 2018
* currently, `fxFlex` listens for container events (e.g. `fxLayout`)
  in the constructor. Unfortunately, this is too eager and sometimes
  takes place before the `fxFlex` value is actually set

Fixes #700
CaerusKaru added a commit that referenced this issue Jun 11, 2018
* fix(fxFlex): do not eagerly listen to layout changes

* currently, `fxFlex` listens for container events (e.g. `fxLayout`)
  in the constructor. Unfortunately, this is too eager and sometimes
  takes place before the `fxFlex` value is actually set

Fixes #700
PR Close #733
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug flexbox has pr A PR has been created to address this issue P0 Critical issue that needs to be resolved immediately
Projects
None yet
2 participants