diff --git a/packages/kbn-unified-field-list/src/components/field_stats/field_top_values_bucket.tsx b/packages/kbn-unified-field-list/src/components/field_stats/field_top_values_bucket.tsx index a53bbcdebc468..64d4c75e228ce 100755 --- a/packages/kbn-unified-field-list/src/components/field_stats/field_top_values_bucket.tsx +++ b/packages/kbn-unified-field-list/src/components/field_stats/field_top_values_bucket.tsx @@ -211,8 +211,14 @@ const FieldTopValuesBucket: React.FC = ({ ); }; +// copied from x-pack/plugins/banners/server/utils.ts +const hexColorRegexp = /^#([0-9a-f]{6}|[0-9a-f]{3})$/i; +const isHexColor = (color: string) => { + return hexColorRegexp.test(color); +}; + const getPercentageColor = (euiTheme: EuiThemeComputed, color: string) => - euiTheme.themeName?.toLowerCase().includes('borealis') + euiTheme.themeName?.toLowerCase().includes('borealis') && isHexColor(color) ? makeHighContrastColor(color)(euiTheme) : color; // FIXME: remove in 9.x when Borealis becomes the default theme