Fix chart color resolution by querying FluentProvider wrapper
The pie and bar charts were rendering with transparent/missing colors because resolveFluentToken queried document.documentElement for CSS custom properties. Fluent UI v9 injects these on its own wrapper div (.fui-FluentProvider), not on :root. Changed to query that element with a fallback to document.html. This fixes the fill colors for all four chart components.
This commit is contained in:
@@ -30,7 +30,12 @@ import { tokens } from "@fluentui/react-components";
|
||||
export function resolveFluentToken(tokenValue: string): string {
|
||||
const match = /var\((--[^,)]+)/.exec(tokenValue);
|
||||
if (match == null || match[1] == null) return tokenValue;
|
||||
const resolved = getComputedStyle(document.documentElement)
|
||||
|
||||
// FluentProvider injects CSS custom properties on its own wrapper <div>,
|
||||
// not on :root. Query that element so we resolve actual colour values.
|
||||
const el =
|
||||
document.querySelector(".fui-FluentProvider") ?? document.documentElement;
|
||||
const resolved = getComputedStyle(el)
|
||||
.getPropertyValue(match[1])
|
||||
.trim();
|
||||
return resolved !== "" ? resolved : tokenValue;
|
||||
|
||||
Reference in New Issue
Block a user