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

bug(material/slide-toggle): Sass deprecation warning since v18.2.0 #29591

Closed
1 task done
json-derulo opened this issue Aug 15, 2024 · 8 comments · Fixed by #29596
Closed
1 task done

bug(material/slide-toggle): Sass deprecation warning since v18.2.0 #29591

json-derulo opened this issue Aug 15, 2024 · 8 comments · Fixed by #29596
Assignees
Labels
area: material/slide-toggle P2 The issue is important to a large percentage of users, with a workaround

Comments

@json-derulo
Copy link
Contributor

json-derulo commented Aug 15, 2024

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

18.1.x

Description

After updating to Angular 18.2.0 in an app using Angular Material with a custom theme, the following Sass warning is produced:

▲ [WARNING] Deprecation [plugin angular-sass]

    node_modules/@angular/material/slide-toggle/_slide-toggle-theme.scss:46:6:
      46 │       --mdc-switch-disabled-label-text-color: #{inspection.get-the...
         ╵       ^

          $theme,
          foreground,
          disabled-text
        )};

  Sass's behavior for declarations that appear after nested
  rules will be changing to match the behavior specified by CSS in an upcoming
  version. To keep the existing behavior, move the declaration above the nested
  rule. To opt into the new behavior, wrap the declaration in `& {}`.
  
  More info: https://sass-lang.com/d/mixed-decls

The warning originates from the Slide Toggle theme:

--mdc-switch-disabled-label-text-color: #{inspection.get-theme-color(

Reproduction

StackBlitz link: https://stackblitz.com/edit/tq6jmr?file=src%2Fstyles.scss
Steps to reproduce:

  1. Build / start the project

Expected Behavior

No Sass warning produced

Actual Behavior

Sass warning is produced

Environment

Angular CLI: 18.2.0
Node: 18.20.3
Package Manager: yarn 1.22.19
OS: linux x64

Angular: 18.2.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, localize, material, material-experimental
... material-moment-adapter, platform-browser
... platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.1802.0
@angular-devkit/build-angular 18.2.0
@angular-devkit/core 18.2.0
@angular-devkit/schematics 18.2.0
@schematics/angular 18.2.0
rxjs 7.4.0
typescript 5.4.5
zone.js 0.14.6

@json-derulo json-derulo added the needs triage This issue needs to be triaged by the team label Aug 15, 2024
@json-derulo json-derulo changed the title bug(material/slide-toggle): Sass deprecation warning bug(material/slide-toggle): Sass deprecation warning since v18.2.0 Aug 15, 2024
@martinboue
Copy link

Same observation with M3 custom theme.

@crisbeto
Copy link
Member

What version of Sass are you running?

@crisbeto crisbeto self-assigned this Aug 15, 2024
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: material/slide-toggle and removed needs triage This issue needs to be triaged by the team labels Aug 15, 2024
@json-derulo
Copy link
Contributor Author

json-derulo commented Aug 15, 2024

I'm not overriding the Sass version, I'm using the one from @angular-devkit/build-angular. Their sass version is v1.77.8. According to the sass changelog, this warning was added with v1.77.7.

@crisbeto crisbeto added P2 The issue is important to a large percentage of users, with a workaround and removed P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels Aug 16, 2024
crisbeto added a commit to crisbeto/material2 that referenced this issue Aug 16, 2024
crisbeto added a commit to crisbeto/material2 that referenced this issue Aug 16, 2024
@xylplm
Copy link

xylplm commented Aug 17, 2024

I also encountered the same problem after upgrading to Angular 18.2.0

`▲ [WARNING] Deprecation [plugin angular-sass]

node_modules/@angular/material/slide-toggle/_slide-toggle-theme.scss:46:6:
  46 │       --mdc-switch-disabled-label-text-color: #{inspection.get-the...
     ╵       ^

      $theme,
      foreground,
      disabled-text
    )};

Sass's behavior for declarations that appear after nested
rules will be changing to match the behavior specified by CSS in an upcoming
version. To keep the existing behavior, move the declaration above the nested
rule. To opt into the new behavior, wrap the declaration in & {}.

More info: https://sass-lang.com/d/mixed-decls

The plugin "angular-sass" was triggered by this import

angular:styles/global:styles:2:8:
  2 │ @import 'src/assets/scss/style.scss';
    ╵         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

@zwjohn
Copy link

zwjohn commented Aug 17, 2024

The same here

Sass's behavior for declarations that appear after nested
rules will be changing to match the behavior specified by CSS in an upcoming
version. To keep the existing behavior, move the declaration above the nested
rule. To opt into the new behavior, wrap the declaration in & {}.

More info: https://sass-lang.com/d/mixed-decls

The plugin "angular-sass" was triggered by this import

angular:styles/global:styles:1:8:
  1 │ @import 'src/styles.scss';
    ╵         ~~~~~~~~~~~~~~~~~

@PhilFlash
Copy link

Same problem here after upgrading to Angular 18.2.0

``
▲ [WARNING] Deprecation [plugin angular-sass]

node_modules/@angular/material/slide-toggle/_slide-toggle-theme.scss:46:6:
  46 │       --mdc-switch-disabled-label-text-color: #{inspection.get-the...
     ╵       ^

      $theme,
      foreground,
      disabled-text
    )};

Sass's behavior for declarations that appear after nested
rules will be changing to match the behavior specified by CSS in an upcoming
version. To keep the existing behavior, move the declaration above the nested
rule. To opt into the new behavior, wrap the declaration in & {}.

More info: https://sass-lang.com/d/mixed-decls

The plugin "angular-sass" was triggered by this import

angular:styles/global:theme-purple:1:8:
  1 │ @import 'src/styles/_theme_purple.scss';
    ╵         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``

crisbeto added a commit to crisbeto/material2 that referenced this issue Aug 20, 2024
crisbeto added a commit to crisbeto/angular-cli that referenced this issue Aug 20, 2024
In 18.2 the Sass version was updated to 1.77.7 which causes a lot of deprecation warnings for Material users (see angular/components#29591). Resolving these warnings can break some apps so we want to delay it until v19.

These changes downgrade to a version that doesn't check for the deprecation.
@crisbeto
Copy link
Member

Following up here: fixing these deprecation warnings will change the order in which some CSS will be generated which can break some users so we want to delay them until v19. To address the issue we'll:

  1. Downgrade the CLI to a version before the warning started being logged (see build: downgrade sass version angular-cli#28234). If you're managing the Sass dependency yourself, you should set the version to be lower than 1.77.7.
  2. Land fix(multiple): account for mixed declarations in latest Sass version #29596 in v19.
  3. Talk to the Sass team to see if there's a better way to handle it on our end, like potentially a new syntax.

crisbeto added a commit to crisbeto/material2 that referenced this issue Aug 20, 2024
Fixes a ton of warnings that showed up in the latest version of Sass as a result of https://sass-lang.com/documentation/breaking-changes/mixed-decls/.

BREAKING CHANGES:
* In order for Material to be compatible with [recent changes in Sass](https://sass-lang.com/documentation/breaking-changes/mixed-decls/) and upcoming changes in the CSS standard, tokens are now emitted in-place, rather the being hoisted to the top of the selector. As a result, some token overrides might not apply anymore. This is relevant primarily for the cases like `@include mat.button-theme($theme); --mat-button-color: red;`. It can be resolved by wrapping the overrides with `& {}`, for example `@include mat.button-theme($theme); & { --mat-button-color: red; }`.

Fixes angular#29591.
alan-agius4 pushed a commit to angular/angular-cli that referenced this issue Aug 20, 2024
In 18.2 the Sass version was updated to 1.77.7 which causes a lot of deprecation warnings for Material users (see angular/components#29591). Resolving these warnings can break some apps so we want to delay it until v19.

These changes downgrade to a version that doesn't check for the deprecation.
crisbeto added a commit to crisbeto/material2 that referenced this issue Aug 20, 2024
Fixes a ton of warnings that showed up in the latest version of Sass as a result of https://sass-lang.com/documentation/breaking-changes/mixed-decls/.

BREAKING CHANGE:
* In order for Material to be compatible with [recent changes in Sass](https://sass-lang.com/documentation/breaking-changes/mixed-decls/) and upcoming changes in the CSS standard, tokens are now emitted in-place, rather the being hoisted to the top of the selector. As a result, some token overrides might not apply anymore. This is relevant primarily for the cases like `@include mat.button-theme($theme); --mat-button-color: red;`. It can be resolved by wrapping the overrides with `& {}`, for example `@include mat.button-theme($theme); & { --mat-button-color: red; }`.

Fixes angular#29591.
crisbeto added a commit that referenced this issue Aug 20, 2024
…29596)

Fixes a ton of warnings that showed up in the latest version of Sass as a result of https://sass-lang.com/documentation/breaking-changes/mixed-decls/.

BREAKING CHANGE:
* In order for Material to be compatible with [recent changes in Sass](https://sass-lang.com/documentation/breaking-changes/mixed-decls/) and upcoming changes in the CSS standard, tokens are now emitted in-place, rather the being hoisted to the top of the selector. As a result, some token overrides might not apply anymore. This is relevant primarily for the cases like `@include mat.button-theme($theme); --mat-button-color: red;`. It can be resolved by wrapping the overrides with `& {}`, for example `@include mat.button-theme($theme); & { --mat-button-color: red; }`.

Fixes #29591.
@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 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/slide-toggle P2 The issue is important to a large percentage of users, with a workaround
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants