Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[fix] add autoCreateTooltips as a prop in AddDataToMapOptions (#2358)

Igor Dykhtafa1edab91f9c
diff --git a/src/reducers/src/combined-updaters.ts b/src/reducers/src/combined-updaters.ts
index e4443b6e7..cba9e01ed 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 a7461b75d..1f1141444 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 373253b72..8c96a7796 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 = {