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

Materialize.updateTextFields messing up my class.active logic #93

Open
ghost opened this issue Aug 26, 2016 · 1 comment
Open

Materialize.updateTextFields messing up my class.active logic #93

ghost opened this issue Aug 26, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Aug 26, 2016

Hi

Line:
https://github.com/InfomediaLtd/angular2-materialize/blame/master/src/materialize-directive.ts#L94

Consider the following line of my app
<input [(ngModel)]="costprice.name"...
<label for="name" [class.active]="costprice.name || invalidKeys['name']">Name</label>

Issue:
class.active is not set even if costprice.name value exists.

Reason:
Before I had no issue, then I added later in the template a select with materialize="material_select" and the issue appeared. Apparently because of that materialize= that performElementUpdates is called and so updateTextFields, at the wrong moment.

I guess somehow the flow is :
(after costprice object is resolved)

  • Process class.active logic
  • ngAfterViewInit kicks in, performElementUpdates and updateTextFields are called but as the [(ngModel)]'s value is not yet filled in the input, class.active is removed by Materialize
  • [(ngModel)]'s value is filled

Conclusion my class.active logic is overridden.

My solution for now was to remove the line materialize-directive.ts#L94 to perform updateTextFields myself.

But I am not happy with the solution...

Is my code wrongly designed ?
Is materialize-directive.ts#L94 legitimate ?
Any idea for a better solution ?

@leonardobazico
Copy link
Contributor

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant