Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 18b8f31

Browse files
codrcopybara-github
authored andcommitted
feat(select): do not emit styles when calling theme-styles(()).
PiperOrigin-RevId: 489980365
1 parent 96f4726 commit 18b8f31

File tree

3 files changed

+56
-12
lines changed

3 files changed

+56
-12
lines changed

packages/mdc-select/_select-shared-theme.scss

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@
3434
@function _resolve-theme-elevation($theme, $resolver) {
3535
$elevation: map.get($theme, menu-container-elevation);
3636
$shadow-color: map.get($theme, menu-container-shadow-color);
37-
$resolved-value: meta.call(
38-
$resolver,
39-
$elevation: $elevation,
40-
$shadow-color: $shadow-color
41-
);
42-
$theme: map.set($theme, menu-container-elevation, $resolved-value);
37+
@if $elevation and $shadow-color {
38+
$resolved-value: meta.call(
39+
$resolver,
40+
$elevation: $elevation,
41+
$shadow-color: $shadow-color
42+
);
43+
$theme: map.set($theme, menu-container-elevation, $resolved-value);
44+
}
4345
@return $theme;
4446
}

packages/mdc-select/_select-theme.scss

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -707,11 +707,13 @@ $_light-theme: (
707707
}
708708

709709
@mixin _menu-container-elevation($elevation) {
710-
.mdc-select__menu {
711-
@include elevation-theme.shadow(map.get($elevation, shadow));
712-
@include elevation-theme.overlay-opacity(
713-
map.get($elevation, overlay-opacity)
714-
);
710+
@if $elevation {
711+
.mdc-select__menu {
712+
@include elevation-theme.shadow(map.get($elevation, shadow));
713+
@include elevation-theme.overlay-opacity(
714+
map.get($elevation, overlay-opacity)
715+
);
716+
}
715717
}
716718
}
717719

@@ -975,7 +977,10 @@ $_light-theme: (
975977
$query: feature-targeting.all()
976978
) {
977979
@if (meta.type-of($radius) == 'list' and list.length($radius) > 2) and
978-
(list.nth($radius, 3) != 0 or list.nth($radius, 4) != 0)
980+
(
981+
(list.nth($radius, 3) != 0 and list.nth($radius, 3) != 0px) or
982+
(list.nth($radius, 4) != 0 and list.nth($radius, 4) != 0px)
983+
)
979984
{
980985
@error "mdc-select: Invalid radius #{$radius}. Only top-left and top-right corners may be customized.";
981986
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
@use 'third_party/javascript/material_components_web/tokens/v0_132/' as tokens;
2+
@use 'true' as test;
3+
4+
@use '../select-filled-theme';
5+
@use '../select-outlined-theme';
6+
7+
@include test.describe('select-filled-theme') {
8+
@include test.describe('theme-styles()') {
9+
@include test.it('return no styles when no theme is provided') {
10+
@include test.assert {
11+
@include test.output {
12+
@include select-filled-theme.theme-styles(());
13+
}
14+
15+
@include test.expect {
16+
// No content. This is testing that an error isn't thrown.
17+
}
18+
}
19+
}
20+
}
21+
}
22+
23+
@include test.describe('select-outlined-theme') {
24+
@include test.describe('theme-styles()') {
25+
@include test.it('return no styles when no theme is provided') {
26+
@include test.assert {
27+
@include test.output {
28+
@include select-outlined-theme.theme-styles(());
29+
}
30+
31+
@include test.expect {
32+
// No content. This is testing that an error isn't thrown.
33+
}
34+
}
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)