-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(material/snack-bar): incorrect width at some breakpoints #26334
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
@use 'sass:map'; | ||
@use '@angular/cdk'; | ||
@use '@material/snackbar/snackbar' as mdc-snackbar; | ||
@use '@material/snackbar/snackbar-theme' as mdc-snackbar-theme; | ||
@use '../core/mdc-helpers/mdc-helpers'; | ||
|
@@ -10,13 +9,28 @@ | |
@include mdc-snackbar.static-styles($query: mdc-helpers.$mdc-base-styles-without-animation-query); | ||
} | ||
|
||
@mixin _container-min-width { | ||
$min-width: mdc-snackbar-theme.$min-width; | ||
$mobile-breakpoint: mdc-snackbar-theme.$mobile-breakpoint; | ||
|
||
// The styles weren't included in `static-styles` so we need to add them ourselves. | ||
@include mdc-snackbar-theme.min-width( | ||
$min-width: $min-width, | ||
$mobile-breakpoint: $mobile-breakpoint, | ||
$query: mdc-helpers.$mdc-base-styles-query | ||
); | ||
|
||
// The MDC `min-width` mixin has a similar breakpoint that sets `min-width: 100%` on the surface | ||
// element to make it span the entire viewport, however it ends up collapsing because the | ||
// container is `width: auto`. This query ensures that the surface will span the whole viewport. | ||
@media (max-width: $mobile-breakpoint), (max-width: $min-width) { | ||
width: 100vw; | ||
} | ||
} | ||
|
||
.mat-mdc-snack-bar-container { | ||
@include mdc-helpers.disable-mdc-fallback-declarations { | ||
// The styles weren't included in `static-styles` so we need to add them ourselves. | ||
@include mdc-snackbar-theme.min-width( | ||
mdc-snackbar-theme.$min-width, | ||
$query: mdc-helpers.$mdc-base-styles-query | ||
); | ||
@include _container-min-width; | ||
@include mdc-snackbar-theme.max-width( | ||
mdc-snackbar-theme.$max-width, | ||
$query: mdc-helpers.$mdc-base-styles-query | ||
|
@@ -60,10 +74,6 @@ | |
// of positions, so we'll defer logic there. | ||
position: static; | ||
|
||
@include cdk.high-contrast(active, off) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated change. I just noticed that we don't need it anymore. |
||
border: solid 1px; | ||
} | ||
|
||
// The `mat-mdc-button` and `:not(:disabled)` here are redundant, but we need them to increase | ||
// the specificity over the button styles that may bleed in from the rest of the app. | ||
.mat-mdc-button.mat-mdc-snack-bar-action:not(:disabled) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we open an issue OR code change with MDC for this? It seems like
100vw
more closely matches the intent of their styleThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MDC would've been 100vw as well, but we override their
position: fixed
positioning in order to fit the snack bar in our overlay positioning model.