bito-code-review[bot] commented on PR #44557:
URL: https://github.com/apache/superset/pull/44557#issuecomment-5803439363
<!-- Bito Reply -->
The observation is correct. The core of the fix is indeed the transition
from a simple boolean `dashboardLabelsColorInitiated` to
`colorInitializedDashboardId`, which allows the component to re-initialize
colors when the `dashboardInfo.id` changes. By tying
`dashboardLabelsColorInitiated` to the current `dashboardInfo.id`, the
component correctly triggers `applyDashboardLabelsColorOnLoad` again during
in-app navigation, ensuring the new dashboard's palette is applied. The
addition of the conditional rendering `{dashboardLabelsColorInitiated &&
renderParentSizeChildren({ width })}` further ensures that the grid (and its
cached charts) only mounts once the colors are ready, preventing the race
condition where charts might consume default colors before the custom palette
is applied.
**superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx**
```
const [colorInitializedDashboardId, setColorInitializedDashboardId] =
useState<number | null>(null);
const dashboardLabelsColorInitiated =
colorInitializedDashboardId === dashboardInfo?.id;
```
**superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx**
```
{/* Defer the grid until hydration and color initialization complete,
before cached charts consume their color scales on first render.
*/}
{dashboardLabelsColorInitiated && renderParentSizeChildren({ width })}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]