ngx-formly / ngx-formly

📝 JSON powered / Dynamic forms for Angular
https://formly.dev
MIT License
2.81k stars 566 forks source link

fieldGroupClassName work without setting encapsulation to be ViewEncapsulation.None #1310

Closed ron-liu closed 5 years ago

ron-liu commented 5 years ago

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[x] support request

Current behavior

Given the sample demo here, I noticed we have to set encapsulation: ViewEncapsulation.None to work wiht fieldGroupClassName. While with this setup, it tend to generate unexpected errors when build with production. If we want to avoid unexpected production error, another approach is to move the classes used by fieldGroupClassNamesome global places.

Expected behavior

fieldGroupClassName should work without setting encapsulation: ViewEncapsulation.None

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

aitboudad commented 5 years ago

well instead of setting encapsulation to none, you can use ::ng-deep selector:

::ng-deep {
  .display-flex { display: flex; }
  .flex-1 { flex: 1; }
  .flex-2 { flex: 2; }
  ...
}
ron-liu commented 5 years ago

Though it will pollute children, it is a lot better than setting encapsulation to none. Fixed my problem, thanks.