Files
George Karrandtest 1dcad647f9 Fix dark-mode contrast of status-filter dropdown selected-value icon (#47581) (#49622)
**Related issue:** Resolves #47581

# Checklist for submitter

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.

## What / why

In dark mode, the status-filter dropdown's selected-value icon on the
Hosts page rendered near-black and was barely visible at rest (only
appearing on hover/open).

The leading filter icon is rendered two different ways, and both were
broken in dark mode:

1. **SVG icon** (`iconName="filter-alt"` — PoliciesFilter,
HostsFilterBlock) renders `.dropdown__custom-value .dropdown__icon`. The
base `Dropdown` only applied a theme-aware `fill` on hover/open; at rest
it fell back to a near-black default. Added a rest-state rule (`fill:
$ui-fleet-black-75`) so the icon is theme-aware at rest. Light mode
resolves to the same color as before (no visual change); dark mode now
uses the light shade.

2. **Black PNG** (`icon-filter-v2-black-16x16@2x.png` via `::before` —
DiskEncryptionStatusFilter, BootstrapPackageStatusFilter) is a hardcoded
black glyph that never adapts to the theme. Added `filter: invert(1)`
scoped to `body.dark-mode` so it becomes a light glyph in dark mode
only.

Frontend/SCSS-only change.

## Testing

- [ ] Added/updated automated tests
- [x] QA'd all new/changed functionality manually

Verify in **dark mode** on the Hosts page:
- Controls → OS settings → Disk encryption → click a status (lands on
`/hosts/manage?...&os_settings_disk_encryption=enforcing`) — the
"Enforcing" filter icon is clearly visible at rest.
- Bootstrap package status filter and policy pass/fail filter icons are
also visible at rest.
- Light mode appearance is unchanged.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Bug Fixes**
  - Improved visibility of selected status-filter icons in dark mode.
- Updated disk encryption, bootstrap package, and policy status filters
on the Hosts page with clearer, theme-aware icons.
- Improved contrast and consistency for dropdown icons across dark-mode
views, preventing selected icons from appearing nearly black or
difficult to see.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: test <test@test.com>
2026-08-05 12:32:08 -05:00

383 lines
7.8 KiB
SCSS

.dropdown {
&__custom-value {
display: inline-flex;
svg {
padding: 0 $pad-small;
}
&-label {
line-height: 38px;
font-size: $x-small;
// Override react-select's hardcoded `.Select-value { color: #aaa; }` so
// the selected value uses themed text color (esp. needed for dark mode).
color: $core-fleet-black;
}
}
&__custom-arrow {
display: flex;
svg {
transition: transform 0.25s ease;
}
}
&__label {
display: block;
font-size: $x-small;
font-weight: $regular;
color: $core-fleet-black;
margin-bottom: $pad-xsmall;
&--error {
font-weight: $bold;
}
}
&__select {
&--error {
&.Select {
.Select-control {
color: $core-vibrant-red;
border: 1px solid $core-vibrant-red;
box-sizing: border-box;
border-radius: $border-radius;
}
.Select-arrow {
border-top-color: $ui-error;
}
}
}
}
&__option {
display: flex;
flex-direction: column;
gap: $pad-small;
width: 100%;
}
&__help-text {
@include help-text;
font-style: italic;
}
}
.Select {
&.dropdown__select {
border: 1px solid $ui-fleet-black-10;
border-radius: $border-radius;
&:hover:not(.is-disabled) {
box-shadow: none;
border-color: $ui-fleet-black-50;
}
}
.Select-control {
background-color: $core-fleet-white;
border: 0;
border-radius: $border-radius;
cursor: pointer;
.Select-value {
font-size: $x-small;
background-color: $core-fleet-white;
}
}
.Select-value {
font-size: $x-small;
border-radius: $border-radius;
background-color: $core-fleet-white;
.Select-value-icon {
border: 0;
float: right;
line-height: 28px;
width: 20px;
padding: 0;
margin: 0 5px;
text-align: center;
font-size: $small;
color: $ui-fleet-black-50;
transition: color 150ms ease-in-out;
&:hover {
color: $core-fleet-black;
}
}
.Select-value-label {
font-size: $x-small;
color: $core-fleet-black;
vertical-align: middle;
}
}
&--single {
> .Select-control {
.Select-value {
line-height: 34px;
border: none;
}
}
}
&.is-focused:not(.is-disabled) {
&.dropdown__select {
border: 1px solid $ui-fleet-black-50;
}
}
// Override react-select's hardcoded white background on focus/open so the
// control stays themed (critical for dark mode).
&.is-focused > .Select-control {
background-color: $core-fleet-white;
}
&.is-focused:not(.is-open) > .Select-control {
box-shadow: none;
border-color: $ui-fleet-black-75; // Override blue border on focus
background-color: $core-fleet-white;
}
// Theme the selected-value icon at rest. Without this the icon falls back to
// its near-black default (SVG fill or #333), which is fine on the light
// control but barely visible against the dark-mode control (#47581). The
// hover/open rules below shift it to the -over shade for interaction
// feedback.
.dropdown__custom-value .dropdown__icon svg path {
fill: $ui-fleet-black-75;
}
&.is-open {
.dropdown__custom-arrow .dropdown__icon {
svg {
transform: rotate(180deg);
transition: transform 0.25s ease;
path {
stroke: $ui-fleet-black-75-over;
}
}
}
.dropdown__custom-value .dropdown__icon {
svg path {
fill: $ui-fleet-black-75-over;
}
}
> .Select-control {
border-radius: $border-radius;
// Override react-select's hardcoded white background when open.
background-color: $core-fleet-white;
}
}
:hover {
.dropdown__custom-arrow .dropdown__icon {
svg {
path {
stroke: $ui-fleet-black-75-over;
}
}
}
.dropdown__custom-value .dropdown__icon {
svg path {
fill: $ui-fleet-black-75-over;
}
}
&.is-open {
.dropdown__custom-arrow .dropdown__icon {
svg path {
stroke: $ui-fleet-black-75-over;
}
}
.dropdown__custom-value .dropdown__icon {
svg path {
fill: $ui-fleet-black-75-over;
}
}
}
}
// react-select v1 ships with `.Select.has-value.Select--single > .Select-control
// .Select-value .Select-value-label { color: #333; }` (5-class specificity).
// We must match or beat that selector to theme the displayed value — critical
// for dark mode, where #333 reads as nearly-invisible against the dark control.
&.has-value.Select--single,
&.has-value.is-pseudo-focused.Select--single {
> .Select-control .Select-value .Select-value-label {
color: $core-fleet-black;
font-size: $x-small;
}
}
&.has-value.is-disabled {
> .Select-control .Select-value .Select-value-label {
color: $ui-fleet-black-50;
}
}
.Select-menu-outer {
background-color: $core-fleet-white;
box-shadow: 0 0 0 1px $ui-fleet-black-10;
z-index: 6;
overflow: hidden;
max-height: 198px; // Fits 4 options without scrolling
border: 0;
margin: 1px 0 0;
padding: $pad-small;
animation: fade-in 150ms ease-out;
}
.Select-menu {
max-height: 182px; // Scrollable within .Select-menu-outer
overflow-y: auto;
}
.Select-noresults {
font-size: $x-small;
}
.Select-option {
color: $core-fleet-black;
background-color: transparent;
font-size: $x-small;
margin: 0;
padding: 10px;
display: block;
border-radius: $border-radius;
&.is-selected {
background-color: $ui-fleet-black-5;
font-weight: bold;
}
&.is-focused {
background-color: $ui-fleet-black-5;
.Select-icon {
color: $ui-fleet-black-10;
}
}
&:active {
background-color: $ui-fleet-black-75-down;
}
&:last-child {
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
&.is-disabled {
color: $ui-fleet-black-50;
font-style: italic;
.Select-icon {
visibility: hidden;
opacity: 0;
}
}
}
.Select-icon {
color: $ui-gray;
}
.Select-placeholder {
color: $ui-fleet-black-50;
font-size: $x-small;
line-height: 34px;
box-sizing: border-box;
}
.Select-clear-zone {
color: $ui-fleet-black-50;
transition: color 150ms ease-in-out;
&:hover {
color: $core-fleet-black;
}
}
.Select-input {
color: $core-fleet-black;
font-size: $x-small;
box-sizing: border-box;
height: 34px;
&:focus {
background: transparent;
}
> input {
line-height: 34px;
padding: 0;
}
}
&.Select--multi {
.Select-control {
display: flex;
align-items: center;
height: auto;
}
.Select-multi-value-wrapper {
flex-grow: 1;
.Select-value {
border: 1px solid $ui-fleet-black-50;
vertical-align: middle;
align-items: center;
margin-top: 0;
display: inline-flex;
flex-direction: row-reverse;
.Select-value-icon:hover {
background-color: initial;
}
.Select-value-label {
font-size: $x-small;
align-self: center;
}
}
}
.Select-arrow-zone {
display: flex;
}
.Select-option {
&.is-disabled {
color: $ui-fleet-black-50;
cursor: default;
&.is-focused {
background-color: $ui-fleet-black-10;
color: $core-fleet-white;
}
}
}
.Select-value-label {
padding: 0 0 0 10px;
}
}
.premium-feature-icon {
position: relative;
top: 4px;
margin-left: 3px;
}
}
.form-field {
&__label {
&--disabled {
color: $ui-fleet-black-50;
}
}
}