Skip to content

Commit

Permalink
fix: fix theme initialization of embedded PowerBI reports
Browse files Browse the repository at this point in the history
  • Loading branch information
csm-thu committed Apr 11, 2024
1 parent f0689e4 commit ec79301
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/charts/SimplePowerBIReportEmbed/SimplePowerBIReportEmbed.js
Expand Up @@ -160,12 +160,13 @@ export const SimplePowerBIReportEmbed = ({
tokenType,
embedUrl: reports.data?.reportsInfo?.[reportId]?.embedUrl,
accessToken: reports.data?.accessToken,
theme: { themeJson: theme },
};

addDynamicParameters(pageName, lang, newConfig, settings, staticFilters, additionalFilters);
setEmbedConfig(newConfig);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [lang, scenario, reports.status]);
}, [lang, scenario, reports.status, theme]);

useEffect(() => {
if (theme) {
Expand Down Expand Up @@ -203,16 +204,7 @@ export const SimplePowerBIReportEmbed = ({
let content;
try {
content = (
<PowerBIEmbed
cssClassName={classes.report}
embedConfig={embedConfig}
getEmbeddedComponent={(embedObject) => {
if (theme) {
embedObject.applyTheme({ themeJson: theme });
}
setReport(embedObject);
}}
/>
<PowerBIEmbed cssClassName={classes.report} embedConfig={embedConfig} getEmbeddedComponent={setReport} />
);
} catch (error) {
console.log('Error when intializing the PowerBIEmbed component.');
Expand All @@ -221,7 +213,7 @@ export const SimplePowerBIReportEmbed = ({
}

return content;
}, [classes.report, embedConfig, theme]);
}, [classes.report, embedConfig]);

const placeholder = getPlaceholder();
const isReady = (scenarioState === undefined || scenarioState === 'Successful') && !noScenario;
Expand Down

0 comments on commit ec79301

Please sign in to comment.