From 20714ab5c6b9327ebea78c3a2ee65244efa02757 Mon Sep 17 00:00:00 2001 From: Rui Wang <64480766+albatross97@users.noreply.github.com> Date: Thu, 22 Jun 2023 09:16:50 -0700 Subject: [PATCH] [fix] add autoCreateTooltips as a prop in AddDataToMapOptions Signed-off-by: Ihor Dykhta --- src/reducers/src/combined-updaters.ts | 3 ++- src/reducers/src/vis-state-updaters.ts | 7 ++++++- src/types/actions.d.ts | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/reducers/src/combined-updaters.ts b/src/reducers/src/combined-updaters.ts index e4443b6e74..cba9e01ed8 100644 --- a/src/reducers/src/combined-updaters.ts +++ b/src/reducers/src/combined-updaters.ts @@ -120,7 +120,8 @@ export const isValidConfig = config => export const defaultAddDataToMapOptions = { centerMap: true, keepExistingConfig: false, - autoCreateLayers: true + autoCreateLayers: true, + autoCreateTooltips: true }; /** diff --git a/src/reducers/src/vis-state-updaters.ts b/src/reducers/src/vis-state-updaters.ts index a7461b75d5..1f1141444f 100644 --- a/src/reducers/src/vis-state-updaters.ts +++ b/src/reducers/src/vis-state-updaters.ts @@ -1878,7 +1878,12 @@ function postMergeUpdater(mergedState: VisState, postMergerPayload: PostMergerPa // if no tooltips merged add default tooltips newDataIds.forEach(dataId => { const tooltipFields = mergedState.interactionConfig.tooltip.config.fieldsToShow[dataId]; - if (!Array.isArray(tooltipFields) || !tooltipFields.length) { + // loading dataset: autoCreateTooltips is false and we don't want to run addDefaultTooltips when tooltipFields is empty + if ( + options?.autoCreateTooltips !== false && + (!Array.isArray(tooltipFields) || !tooltipFields.length) + ) { + // adding dataset: autoCreateTooltips is true mergedState = addDefaultTooltips(mergedState, newDataEntries[dataId]); } }); diff --git a/src/types/actions.d.ts b/src/types/actions.d.ts index 373253b720..8c96a77962 100644 --- a/src/types/actions.d.ts +++ b/src/types/actions.d.ts @@ -58,6 +58,7 @@ export type AddDataToMapOptions = { readOnly?: boolean; keepExistingConfig?: boolean; autoCreateLayers?: boolean; + autoCreateTooltips?: boolean; }; export type AddDataToMapPayload = {