Skip to content

Commit

Permalink
Merge pull request #1084 from dhis2/fix/DHIS2-9593-2.35.0
Browse files Browse the repository at this point in the history
fix: unique class name prefix for each map plugin item (DHIS2-9593, 2.35.0 backport)
  • Loading branch information
janhenrikoverland authored Sep 24, 2020
2 parents 9493979 + 7b9cfa8 commit 163db5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maps-app",
"version": "35.0.6",
"version": "35.0.7",
"description": "DHIS2 Maps",
"main": "src/app.js",
"repository": {
Expand Down
9 changes: 5 additions & 4 deletions src/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from '@material-ui/core/styles';
import { union } from 'lodash/fp';
import { init, config, getUserSettings } from 'd2';
import { isValidUid } from 'd2/uid';
import { isValidUid, generateUid } from 'd2/uid';
import log from 'loglevel'; // TODO: Remove version logging
import i18n from './locales';
import Plugin from './components/plugin/Plugin';
Expand All @@ -15,7 +15,6 @@ import {
getExternalLayer,
getBingMapsApiKey,
} from './util/requests';
import { getRenderingStrategy } from './util/analytics';
import { fetchLayer } from './loaders/layers';
import { translateConfig } from './util/favorites';
import { defaultBasemaps } from './constants/basemaps';
Expand Down Expand Up @@ -167,13 +166,15 @@ const PluginContainer = () => {
function drawMap(config) {
if (config.el && !isUnmounted(config.el)) {
const domEl = document.getElementById(config.el);
const rendering = getRenderingStrategy(config);

if (domEl) {
const ref = createRef();

// Used to avoid class names collisions with multiple maps on a dashboard
const id = config.id || generateUid();

const generateClassName = createGenerateClassName({
productionPrefix: `map-plugin-${rendering}-`,
productionPrefix: `map-plugin-${id}-`,
});

render(
Expand Down

0 comments on commit 163db5b

Please sign in to comment.