From 824dc7188b953270ca754f96ca615e96c61dbea4 Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" <70410625+michael-s-molina@users.noreply.github.com> Date: Mon, 14 Nov 2022 08:52:31 -0500 Subject: [PATCH] fix: Right click on country map with code filter (#22081) --- .../cypress/integration/dashboard/drilltodetail.test.ts | 8 ++++---- .../plugins/legacy-plugin-chart-world-map/src/WorldMap.js | 3 ++- .../legacy-plugin-chart-world-map/src/transformProps.js | 2 ++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/superset-frontend/cypress-base/cypress/integration/dashboard/drilltodetail.test.ts b/superset-frontend/cypress-base/cypress/integration/dashboard/drilltodetail.test.ts index f89435f1bc..caf938b33c 100644 --- a/superset-frontend/cypress-base/cypress/integration/dashboard/drilltodetail.test.ts +++ b/superset-frontend/cypress-base/cypress/integration/dashboard/drilltodetail.test.ts @@ -409,14 +409,14 @@ describe('Drill to detail modal', () => { cy.get("[data-test-viz-type='world_map'] svg").then($canvas => { cy.wrap($canvas).scrollIntoView().rightclick(70, 150); - openModalFromChartContext('Drill to detail by United States'); - cy.getBySel('filter-val').should('contain', 'United States'); + openModalFromChartContext('Drill to detail by USA'); + cy.getBySel('filter-val').should('contain', 'USA'); closeModal(); }); cy.get("[data-test-viz-type='world_map'] svg").then($canvas => { cy.wrap($canvas).scrollIntoView().rightclick(200, 140); - openModalFromChartContext('Drill to detail by Slovakia'); - cy.getBySel('filter-val').should('contain', 'Slovakia'); + openModalFromChartContext('Drill to detail by SVK'); + cy.getBySel('filter-val').should('contain', 'SVK'); }); }); }); diff --git a/superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js b/superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js index c845c20da8..7b56d432ea 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js +++ b/superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js @@ -52,6 +52,7 @@ const formatter = getNumberFormatter(); function WorldMap(element, props) { const { + countryFieldtype, entity, data, width, @@ -111,7 +112,7 @@ function WorldMap(element, props) { const pointerEvent = d3.event; pointerEvent.preventDefault(); const key = source.id || source.country; - const val = mapData[key]?.name; + const val = countryFieldtype === 'name' ? mapData[key]?.name : key; if (val) { const filters = [ { diff --git a/superset-frontend/plugins/legacy-plugin-chart-world-map/src/transformProps.js b/superset-frontend/plugins/legacy-plugin-chart-world-map/src/transformProps.js index 71b40e832e..6348874eab 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-world-map/src/transformProps.js +++ b/superset-frontend/plugins/legacy-plugin-chart-world-map/src/transformProps.js @@ -23,6 +23,7 @@ export default function transformProps(chartProps) { chartProps; const { onContextMenu } = hooks; const { + countryFieldtype, entity, maxBubbleSize, showBubbles, @@ -35,6 +36,7 @@ export default function transformProps(chartProps) { const { r, g, b } = colorPicker; return { + countryFieldtype, entity, data: queriesData[0].data, width,