webcat12345 / ngx-ui-switch

Angular UI Switch component
https://webcat12345.github.io/ngx-ui-switch/demo/
MIT License
110 stars 68 forks source link

Broken after upgrading from 6.0.3 to 6.1.1 #297

Closed FrancescoBorzi closed 6 years ago

FrancescoBorzi commented 6 years ago

I've updated my project to use version 6.1.1 (previously I had 6.0.3) and all switches disappeared with no errors in the console.

The <ui-switch> elements are still in the DOM but they have 0x0 dimensions.

Reverting to version 6.0.3 solves the issue for me.

cmckni3 commented 6 years ago

Include the SCSS/CSS

cmckni3 commented 6 years ago

I’ll yank the 6.1 releases and release 7.0 since this is an issue.

FrancescoBorzi commented 6 years ago

@cmckni3 I've tried that and still didn't work

cmckni3 commented 6 years ago

Can you reproduce in stackblitz?

FrancescoBorzi commented 6 years ago

@cmckni3 sure, can you give me a template?

cmckni3 commented 6 years ago

https://stackblitz.com/edit/ngx-ui-switch

FrancescoBorzi commented 6 years ago

I use it with ReactiveForms and it looks like working here: https://stackblitz.com/edit/ngx-ui-switch-whhxxq

So I still don't know what in my codebase is causing the issue but, whatever it is, it's only affecting the newer release version.

I'll further investigate the issue, hoping to reproduce it in a separate environment.

FrancescoBorzi commented 6 years ago

@cmckni3 the issue is the following:

for some reasons if I include the style in a scss file using:

@import '~ngx-ui-switch/ui-switch.component.scss';

then it works. But if I include it in my angular.json (and restart ng serve) then it does not work (I've tried both css and scss files, same problems).

cmckni3 commented 6 years ago

What does styles for your application in angular.json look like? This works for me.

{
  "projects": {
    "demo": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
            "styles": [
              "src/styles.scss",
              "./node_modules/ngx-ui-switch/ui-switch.component.css"
            ],
            "scripts": []
          },
          ...
       }
       ...
    }
}
FrancescoBorzi commented 6 years ago

@cmckni3 I've just realised that I was adding the style to a wrong style set. Everything works fine. Sorry for the confusion.