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.

Styles are not being applied if FormField is wrapped by a custom component

See original GitHub issue

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Styles like errors should be applied.

What is the current behavior?

No styles are being applied.

What are the steps to reproduce?

1 - Click on input and then click outside. 2 - No styles are applied to the input, like red placeholder and others.

Providing a Plunker (or similar) is the best way to get the team to see your issue. https://plnkr.co/edit/Y4bkpFX7Wu6VpITnsL5z?p=preview

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

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.4.1
node: 8.1.1
os: linux x64
@angular/animations: 4.3.6
@angular/cdk: 2.0.0-beta.10
@angular/common: 4.3.6
@angular/compiler: 4.3.6
@angular/core: 4.3.6
@angular/forms: 4.3.6
@angular/http: 4.3.6
@angular/material: 2.0.0-beta.10
@angular/platform-browser: 4.3.6
@angular/platform-browser-dynamic: 4.3.6
@angular/platform-server: 4.3.6
@angular/router: 4.3.6
@angular/cli: 1.4.0
@angular/compiler-cli: 4.3.6
@angular/language-service: 4.3.6
typescript: 2.5.2

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
willshowellcommented, Sep 10, 2017
1reaction
dev054commented, Sep 10, 2017

Thanks @willshowell for commenting.

Well, the original plunker is correct. The path can be specified in both getError and hasError methods, like this:

this.formGroup.getError('required', 'password') this.formGroup.hasError('required', 'password')

It’ll call the get method internally, so it works for nested paths… this.formGroup.hasError('required', 'my.nested.path.here')

It’s good to avoid this ugly (IHMO) thing: this.formGroup.get('password').getError('required') this.formGroup.get('password').hasError('required')

Check the source

The control value accessor isn’t missing nothing, I just copied the it from DefaultValueAccessor source. In fact, I could either extends the DefaultValueAccessor and don’t implement nothing.

PS: Your plunker isn’t showing the issue because you forgot to change this:

password has required error? {{ formGroup.get('password').hasError('required', 'password') }}

to:

password has required error? {{ formGroup.get('password').hasError('required') }}

Your plunker working

Read more comments on GitHub >

github_iconTop Results From Across the Web

Styles are not being applied if FormField is wrapped ... - GitHub
No styles are being applied. What are the steps to reproduce? 1 - Click on input and then click outside. 2 - No...
Read more >
Angular Material Style Class not working - Stack Overflow
You need to wrap the input element with a <mat-form-field> and then the Material style is applied. <input matInput .... /> on its...
Read more >
How To Use Styled-Components In React - Smashing Magazine
In this article, you'll learn the basics of styled components and how to properly apply them to your React applications.
Read more >
Wrapping and breaking text - CSS: Cascading Style Sheets
This guide explains the various ways in which overflowing text can be managed in CSS.
Read more >
How To Create Wrapper Components in React with Props
Finally, you are wrapping the code with a div with a className of wrapper that you'll use to add some styling. To add...
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