Skip to content

Commit

Permalink
fix: Right-click on misconfigured World Map (#21697)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina committed Oct 6, 2022
1 parent d6a8218 commit 770f68f
Showing 1 changed file with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {
getNumberFormatter,
getSequentialSchemeRegistry,
CategoricalColorNamespace,
logging,
t,
} from '@superset-ui/core';
import Datamap from 'datamaps/dist/datamaps.world.min';
import { ColorBy } from './utils';
Expand Down Expand Up @@ -108,16 +110,26 @@ function WorldMap(element, props) {
const handleContextMenu = source => {
const pointerEvent = d3.event;
pointerEvent.preventDefault();
const val = mapData[source.id || source.country].name;
const filters = [
{
col: entity,
op: '==',
val,
formattedVal: val,
},
];
onContextMenu(filters, pointerEvent.clientX, pointerEvent.clientY);
const key = source.id || source.country;
const val = mapData[key]?.name;
if (val) {
const filters = [
{
col: entity,
op: '==',
val,
formattedVal: val,
},
];
onContextMenu(filters, pointerEvent.clientX, pointerEvent.clientY);
} else {
logging.warn(
t(
`Unable to process right-click on %s. Check you chart configuration.`,
),
key,
);
}
};

const map = new Datamap({
Expand Down

0 comments on commit 770f68f

Please sign in to comment.