bito-code-review[bot] commented on code in PR #44148:
URL: https://github.com/apache/superset/pull/44148#discussion_r4155151200
##########
superset-frontend/plugins/plugin-chart-world-map/src/WorldMap.ts:
##########
@@ -191,7 +193,8 @@ function WorldMap(element: HTMLElement, props:
WorldMapProps): void {
const selected = Object.values(filterState.selectedValues || {});
const key = source.id || source.country;
const country =
- countryFieldtype === 'name' ? mapData[key]?.name : mapData[key]?.code;
+ mapData[key]?.sourceValue ??
+ (countryFieldtype === 'name' ? mapData[key]?.name : mapData[key]?.code);
Review Comment:
<!-- Bito Reply -->
The implementation correctly addresses the suggestion by extracting the
logic into a helper function, ensuring consistency between the cross-filter and
context-menu handlers. The changes maintain the existing sourceValue preference
and name/code fallback logic as requested.
**superset-frontend/plugins/plugin-chart-world-map/src/WorldMap.ts**
```
const selected = Object.values(filterState.selectedValues || {});
const key = source.id || source.country;
const country =
mapData[key]?.sourceValue ??
(countryFieldtype === 'name' ? mapData[key]?.name :
mapData[key]?.code);
```
##########
superset-frontend/plugins/plugin-chart-country-map/src/CountryMap.ts:
##########
@@ -178,6 +182,13 @@ function CountryMap(element: HTMLElement, props:
CountryMapProps) {
// Track mouse position to distinguish clicks from drags
let mousedownPos: { x: number; y: number } | null = null;
+ const sourceValue = (code: string) => {
+ if (!sourceValues) return code;
+ return Object.prototype.hasOwnProperty.call(sourceValues, code)
+ ? sourceValues[code]
+ : undefined;
+ };
Review Comment:
<!-- Bito Reply -->
The addressed suggestion regarding the untested guard behavior is valid and
appropriate. By implementing component tests that cover both mapped and
unmapped regions for click and context-menu interactions, the code now
correctly exercises the logic that suppresses interactions on undefined
regions, ensuring the new guard behavior is verified.
--
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]