bito-code-review[bot] commented on PR #42502:
URL: https://github.com/apache/superset/pull/42502#issuecomment-5100198263
<!-- Bito Reply -->
The flagged issue is correct. The `createChartLayoutItemMap` function
currently uses `!chartLayoutItemMap.has(chartId)` to prevent overwriting, which
causes it to discard any subsequent layout holders for the same `meta.chartId`.
To resolve this, the map should store an array of layout items for each
`chartId` instead of a single item, or aggregate the parent paths of all
holders for that chart ID.
Here is a concise fix to store an array of layout items per chart ID:
```typescript
export function createChartLayoutItemMap(
layoutItems: readonly (LayoutItem | null | undefined)[],
): Map<number, LayoutItem[]> {
const chartLayoutItemMap = new Map<number, LayoutItem[]>();
layoutItems.forEach(layoutItem => {
const chartId = layoutItem?.meta?.chartId;
if (layoutItem?.type === CHART_TYPE && typeof chartId === 'number') {
const items = chartLayoutItemMap.get(chartId) || [];
items.push(layoutItem);
chartLayoutItemMap.set(chartId, items);
}
});
return chartLayoutItemMap;
}
```
Would you like me to fetch all other comments on this PR to validate and
implement fixes for them as well?
**superset-frontend/src/dashboard/util/getChartIdsInFilterScope.ts**
```
export function createChartLayoutItemMap(
layoutItems: readonly (LayoutItem | null | undefined)[],
): Map<number, LayoutItem[]> {
const chartLayoutItemMap = new Map<number, LayoutItem[]>();
layoutItems.forEach(layoutItem => {
const chartId = layoutItem?.meta?.chartId;
if (layoutItem?.type === CHART_TYPE && typeof chartId === 'number') {
const items = chartLayoutItemMap.get(chartId) || [];
items.push(layoutItem);
chartLayoutItemMap.set(chartId, items);
}
});
return chartLayoutItemMap;
}
```
--
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]