Skip to content

Commit b68ac04

Browse files
committed
fix(form): fixed listbox color when dark theme elevation is enabled
Ref #1075
1 parent e79993d commit b68ac04

File tree

4 files changed

+64
-7
lines changed

4 files changed

+64
-7
lines changed

packages/form/src/_variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ $rmd-form-theme-values: (
7676
label-top-offset: 0px,
7777
label-active-padding: 0px,
7878
label-active-background-color: transparent,
79+
listbox-background-color: $rmd-listbox-background-color,
7980
text-padding-left: 0px,
8081
text-padding-right: 0px,
8182
text-padding-top: 0px,

packages/form/src/select/_mixins.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@
120120

121121
&--temporary {
122122
@include rmd-elevation($rmd-listbox-elevation);
123-
@include rmd-theme-dark-elevation($rmd-listbox-elevation);
124-
@include rmd-theme(background-color, surface);
123+
@include rmd-form-theme(background-color, listbox-background-color);
125124
@include rmd-theme(color, on-surface);
126125

127126
z-index: $rmd-listbox-z-index;

packages/form/src/select/_variables.scss

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
////
44

55
@import '~@react-md/theme/dist/color-palette';
6+
@import '~@react-md/theme/dist/functions';
67
@import '~@react-md/utils/dist/variables';
78

89
/// The additional amount of apdding to apply to the top of the select field
@@ -17,17 +18,55 @@ $rmd-select-native-multiple-padding: 0.75rem !default;
1718
/// @type Number
1819
$rmd-select-native-addon-top: 1rem !default;
1920

21+
/// The elevation level for a temporary listbox. This should be a number between
22+
/// 0-24 as it generates a material design box shadow value.
23+
/// @type Number
24+
$rmd-listbox-elevation: 8 !default;
25+
26+
/// The background color for a temporary listbox in light themes.
27+
///
28+
/// @type Color
29+
/// @since 2.7.0
30+
$rmd-listbox-light-background-color: rmd-theme-var(surface) !default;
31+
32+
/// The background color for a temporary listbox in dark themes when the
33+
/// `$rmd-theme-dark-elevation` feature flag is also enabled.
34+
///
35+
/// @see $rmd-theme-dark-elevation
36+
/// @require $rmd-theme-dark-elevation-colors
37+
/// @type Color
38+
/// @since 2.7.0
39+
$rmd-listbox-dark-elevation-background-color: map-get(
40+
$rmd-theme-dark-elevation-colors,
41+
$rmd-listbox-elevation
42+
) !default;
43+
44+
/// The background color for a temporary listbox in dark themes.
45+
///
46+
/// @type Color
47+
/// @since 2.7.0
48+
$rmd-listbox-dark-background-color: if(
49+
$rmd-theme-dark-elevation and $rmd-listbox-dark-elevation-background-color,
50+
$rmd-listbox-dark-elevation-background-color,
51+
rmd-theme-var(surface)
52+
) !default;
53+
54+
/// The base background color to apply to temporary listboxes.
55+
///
56+
/// @type Color
57+
/// @since 2.7.0
58+
$rmd-listbox-background-color: if(
59+
$rmd-theme-light,
60+
$rmd-listbox-light-background-color,
61+
$rmd-listbox-dark-background-color
62+
) !default;
63+
2064
/// The z-index to use for a temporary listbox.
2165
///
2266
/// @require $rmd-utils-temporary-element-z-index
2367
/// @type Number
2468
$rmd-listbox-z-index: $rmd-utils-temporary-element-z-index !default;
2569

26-
/// The elevation level for a temporary listbox. This should be a number between
27-
/// 0-24 as it generates a material design box shadow value.
28-
/// @type Number
29-
$rmd-listbox-elevation: 8 !default;
30-
3170
/// The styles to apply when an option is focused with `aria-activedescendant`
3271
/// behavior. This should be a map of styles that should be applied.
3372
///

packages/theme/src/_mixins.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,15 @@
231231
text-filled-color,
232232
$rmd-text-field-filled-light-background-color
233233
);
234+
235+
@if $rmd-listbox-light-background-color !=
236+
$rmd-listbox-dark-background-color
237+
{
238+
@include rmd-form-theme-update-var(
239+
listbox-background-color,
240+
$rmd-listbox-light-background-color
241+
);
242+
}
234243
}
235244

236245
@if mixin-exists(rmd-menu-theme-update-var) {
@@ -415,6 +424,15 @@
415424
text-filled-color,
416425
$rmd-text-field-filled-dark-background-color
417426
);
427+
428+
@if $rmd-listbox-light-background-color !=
429+
$rmd-listbox-dark-background-color
430+
{
431+
@include rmd-form-theme-update-var(
432+
listbox-background-color,
433+
$rmd-listbox-dark-background-color
434+
);
435+
}
418436
}
419437

420438
@if mixin-exists(rmd-menu-theme-update-var) {

0 commit comments

Comments
 (0)