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(experimental): missing box-shadow css rule on elevated containers with material 3 theme #28618

Closed
1 task done
MikaStark opened this issue Feb 20, 2024 · 3 comments · Fixed by #29240
Closed
1 task done
Assignees
Labels
M3 P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@MikaStark
Copy link

MikaStark commented Feb 20, 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

No response

Description

Hi ✋
In the current implementation of the experimental Material 3 themes, the mat-elevation-z* CSS classes lack the box-shadow rule. It appears to be a deliberate design choice, as Material 3 themes exclusively generate CSS custom variables.

To address this issue, we have two potential solutions:

  1. SCSS Mixin Approach:
    Add an SCSS mixin that generates all mat-elevation-z* classes from 0 to 24, applying the necessary box-shadow rules. Here's an example of the mixin:

    @mixin elevations() {
      @for $elevation from 0 to 24 {
        .mat-elevation-z#{$elevation} {
          @include mat.elevation($elevation);
        }
      }
    }
  2. Directive Update Approach:
    Remove the usage of mat-elevation-z* classes in all directives (e.g., mat-menu), replacing them with the box-shadow CSS rule. Utilize a CSS custom property for flexibility, such as:

    var(--mat-elevation-shadow-z8) or var(--mat-menu-shadow)

Additional Suggestion:
Introduce a theme API, mat.get-shadow, which returns the box-shadow for a given elevation value. This API would function similarly to the existing mat.elevation(x) mixin but solely returns the value without applying it.

These enhancements aim to provide flexibility and address the missing box-shadow rule in a manner consistent with the Material 3 design choices.

Reproduction

StackBlitz link: https://stackblitz.com/edit/components-issue-n9d5rj
Steps to reproduce:

  1. Click on menu button
  2. See shadow is missing on opened menu panel

Expected Behavior

Elevated containers such like opened menu panels should have a shadow

Actual Behavior

No shadow

Environment

  • Angular: 17.2.0
  • CDK/Material: 17.2.0
  • Browser(s): All
  • Operating System (e.g. Windows, macOS, Ubuntu): All
@MikaStark MikaStark added the needs triage This issue needs to be triaged by the team label Feb 20, 2024
@mmalerba mmalerba added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent M3 and removed needs triage This issue needs to be triaged by the team labels Mar 19, 2024
@Akxe
Copy link

Akxe commented Jun 3, 2024

My main concern is that not even the Angular Material guides reflect the fact they got removed. The example https://material.angular.io/guide/elevation does a toggle that ends up not making any difference.

@mrmokwa
Copy link

mrmokwa commented Jun 4, 2024

Yeah, this is a breaking change that has not been documented. IMO, it should get a higher priority, since it breaks many applications that depends on this feature/behavior.

Here is the spec for shadows in MD3

@crisbeto crisbeto self-assigned this Jun 12, 2024
crisbeto added a commit to crisbeto/material2 that referenced this issue Jun 12, 2024
Fixes that we didn't support elevation classes in M3 which was breaking some users.

Fixes angular#28618.
crisbeto added a commit to crisbeto/material2 that referenced this issue Jun 12, 2024
Fixes that we didn't support elevation classes in M3 which was breaking some users.

Fixes angular#28618.
crisbeto added a commit to crisbeto/material2 that referenced this issue Jun 13, 2024
Fixes that we didn't support elevation classes in M3 which was breaking some users.

Fixes angular#28618.
crisbeto added a commit that referenced this issue Jun 13, 2024
Fixes that we didn't support elevation classes in M3 which was breaking some users.

Fixes #28618.
crisbeto added a commit that referenced this issue Jun 13, 2024
Fixes that we didn't support elevation classes in M3 which was breaking some users.

Fixes #28618.

(cherry picked from commit a4846a9)
@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 Jul 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
M3 P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants