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

Problem bind [(ngModel)] using material <md-radio-group> component with flexLayout #322

Closed
GustavoCostaW opened this issue Jun 22, 2017 · 22 comments
Labels
can be closed? P3 Important issue that needs to be resolved related: material2

Comments

@GustavoCostaW
Copy link

GustavoCostaW commented Jun 22, 2017

Hey people,

I'm using
Angular Material beta 7
Angular Flex Layout beta 8

I have a component with the following code snippet

{{question.answer}}
<md-radio-group [(ngModel)]="question.answer" name="question{{i}}">
               <div id="problem" *ngFor="let alternative of question.alternatives" fxLayout>
                  <md-radio-button [value]="alternative.id">
                    {{alternative.title}}
                  </md-radio-button>
                  <div>remove<div>
                </div>
</md-radio-group>

if the div#problem has fxLayout directive the [(ngModel)]="question.answer" in md-radio-group doesn't bind when the component is started, see below behavior when div#problem does not have fxLayout directive:

example2

But if I add fxLayout directive, the bind does not work when the component is started.

example1

Demo: http://plnkr.co/edit/k3xXPY?p=preview
Simulate the behavior when you remove fxLayout in div#problem

Is the directive blocking the Angular Material of changing css?

@ThomasBurleson
Copy link
Contributor

@GustavoCostaW - please provide a Plunkr demo or source code to reproduce this issue.

@GustavoCostaW
Copy link
Author

GustavoCostaW commented Jun 22, 2017

@ThomasBurleson done! Simulate the behavior when you remove fxLayout in div#problem

http://plnkr.co/edit/k3xXPY?p=preview

@ThomasBurleson
Copy link
Contributor

ThomasBurleson commented Jun 22, 2017

@GustavoCostaW - this is not a @angular/flex-layout issue.

Here is a Plunkr Demo without any fxLayout directives.

Notice that by simply adding a class="" to the radio button div parent then the selected button highlight at startup fails:

screen shot 2017-06-22 at 10 20 41 am

This is some weird issue with @angular/material.

@ThomasBurleson
Copy link
Contributor

ThomasBurleson commented Jun 22, 2017

Closing as not an @angular/flex-layout issue. Please report this issue on the @angular/material repository.

@GustavoCostaW
Copy link
Author

Hey @ThomasBurleson, thank you for the reply! I will make this :-)

@ThomasBurleson
Copy link
Contributor

Reopening:

@ThomasBurleson could you take a look at this plunker?

http://plnkr.co/edit/sVbxtBHtaXS9mh9ZC4ns?p=preview

It distills the problem down to a bare minimum. You can see on line 94 of main.ts that importing FlexLayoutModule causes the issue.

@ThomasBurleson ThomasBurleson added this to the v2.0.0-beta.9 milestone Jun 22, 2017
@ThomasBurleson ThomasBurleson added the P2 Issue that is important to resolve as soon as possible label Jun 22, 2017
@Splaktar
Copy link
Member

Splaktar commented Jul 5, 2017

Could this be related to #127?

@ThomasBurleson
Copy link
Contributor

This Plunkr with latest build of FlexLayoutModule and latest release of Material shows everything working properly.

Closing as not-an-issue.

@etiennecrb
Copy link

Hello!
I'm sorry but for me, the Plunkr shows the bug: it works only when you remove the class OR you remove FlexLayoutModule.

Very weird bug!

@ThomasBurleson
Copy link
Contributor

@etiennecrb - indeed. I am inclined to think this is an @angular/material2 bug. Still researching...

@ThomasBurleson ThomasBurleson modified the milestones: v2.0.0-beta.10, v2.0.0-beta.9 Aug 11, 2017
@etiennecrb
Copy link

Adding { descendants: true } in @ContentChildren of MdRadioGroup makes things work.
When FlexLayoutModule is in the project, it appends ng-reflect-class-base on the <div> with the *ngFor and the class attribute. I'm not sure why FlexLayout makes that happen neither how it makes @ContentChildren fail...

@ThomasBurleson
Copy link
Contributor

Oh that is interesting.

The Flex-API defers all class active to the Angular Core ClassDirective; not sure why the core directive adds ng-reflect-class-base.

Can you report these findings as an issue with RadioGroup on the @angular/material2 repos ?

@ThomasBurleson
Copy link
Contributor

Closing this as not-an-issue for Flex-Layout.

@epere4
Copy link

epere4 commented Aug 31, 2017

Was any bug in @angular/material2 opened for this in the end?

@etiennecrb
Copy link

No, I haven't opened an issue yet.

@ThomasBurleson
Copy link
Contributor

ThomasBurleson commented Aug 31, 2017

@epere4, @etiennecrb - This has NOT been fixed in the latest Material2 release.

@ThomasBurleson
Copy link
Contributor

After discussions with Angular material team, we are reopening for further investigation.

@ThomasBurleson
Copy link
Contributor

Refs #394 - May be fixed with removal of [class] selector.

@ThomasBurleson
Copy link
Contributor

ThomasBurleson commented Aug 31, 2017

      <md-radio-group [(ngModel)]="question.answer" style="height:200px" name="answer">
        <div *ngFor="let alternative of question.alternatives" id="problem">
          <md-radio-button [value]="alternative.id"> {{alternative.title}} </md-radio-button>
          <div>remove</div>
        </div>
      </md-radio-group>

creates

Working


<md-radio-group [(ngModel)]="question.answer" style="height:200px" name="answer">
  <div id="problem" fxLayout *ngFor="let alternative of question.alternatives" >
    <md-radio-button [value]="alternative.id"> {{alternative.title}} </md-radio-button>
    <div>remove</div>
  </div>
</md-radio-group>

creates

With fxLayout

@devversion - something is interfering with mat-radio-checked being assigned as an additional class.

@ThomasBurleson ThomasBurleson added P3 Important issue that needs to be resolved and removed P2 Issue that is important to resolve as soon as possible labels Aug 31, 2017
@ThomasBurleson ThomasBurleson modified the milestones: v2.0.1-beta.10, v2.0.1-rc.1 Nov 4, 2017
@CaerusKaru
Copy link
Member

Is this still an issue?

@CaerusKaru
Copy link
Member

Closing since this hasn't been updated in a while. We can re-open if a followup is provided confirming this is still an issue.

@CaerusKaru CaerusKaru removed this from the Backlog milestone Dec 19, 2018
@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
can be closed? P3 Important issue that needs to be resolved related: material2
Projects
None yet
Development

No branches or pull requests

6 participants