Skip to content

Commit 0868729

Browse files
authored
Fix bad contrast for highlighted search results in tables (#9863)
* Fix bad contrast for highlighted search results in tables `searchMatchColorOpaque` and `activeSearchMatchColorOpaque` are blended over the row background to highlight search matches. They were migrated from `withOpacity(0.5)` to `withValues(alpha: 255 / 2)` in #8784; since `withValues` expects alpha in the range 0.0-1.0, `255 / 2` clamps to fully opaque. Matched rows then got a solid yellow/orange background while the row text kept its theme color, making it unreadable (especially in dark mode). Restore the intended 0.5 alpha so the highlight stays translucent and the row text remains legible, and add a regression test. Fixes #9010 * Rename search match colors to *Translucent; add release note
1 parent a549a2e commit 0868729

4 files changed

Lines changed: 20 additions & 6 deletions

File tree

packages/devtools_app/lib/src/shared/table/_table_row.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ class _TableRowState<T> extends State<TableRow<T>>
324324
final searchAwareBackgroundColor = isSearchMatch
325325
? Color.alphaBlend(
326326
isActiveSearchMatch
327-
? activeSearchMatchColorOpaque
328-
: searchMatchColorOpaque,
327+
? activeSearchMatchColorTranslucent
328+
: searchMatchColorTranslucent,
329329
backgroundColor,
330330
)
331331
: backgroundColor;

packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ To learn more about DevTools, check out the
1515

1616
## General updates
1717

18-
TODO: Remove this section if there are not any updates.
18+
* Fixed a bug where highlighted search matches in tables were unreadable in dark
19+
mode because the highlight color had become fully opaque. -
20+
[#9863](https://github.com/flutter/devtools/pull/9863)
1921

2022
## Inspector updates
2123

packages/devtools_app_shared/lib/src/ui/theme/theme.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,11 @@ const darkColorScheme = ColorScheme(
224224
);
225225

226226
const searchMatchColor = Colors.yellow;
227-
final searchMatchColorOpaque = Colors.yellow.withValues(alpha: 255 / 2);
227+
final searchMatchColorTranslucent = Colors.yellow.withValues(alpha: 0.5);
228228
const activeSearchMatchColor = Colors.orangeAccent;
229-
final activeSearchMatchColorOpaque =
230-
Colors.orangeAccent.withValues(alpha: 255 / 2);
229+
final activeSearchMatchColorTranslucent = Colors.orangeAccent.withValues(
230+
alpha: 0.5,
231+
);
231232

232233
/// Gets an alternating color to use for indexed UI elements.
233234
Color alternatingColorForIndex(int index, ColorScheme colorScheme) {

packages/devtools_app_shared/test/ui/theme_test.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,15 @@ void main() {
9999
);
100100
});
101101
});
102+
103+
group('search match colors', () {
104+
// Regression test for https://github.com/flutter/devtools/issues/9010: the
105+
// "opaque" search match colors are blended over the row background, so they
106+
// must stay translucent. Otherwise the (theme-colored) row text is drawn on
107+
// a fully opaque highlight and becomes unreadable.
108+
test('are translucent so row text stays legible', () {
109+
expect(searchMatchColorTranslucent.a, closeTo(0.5, 0.001));
110+
expect(activeSearchMatchColorTranslucent.a, closeTo(0.5, 0.001));
111+
});
112+
});
102113
}

0 commit comments

Comments
 (0)