Skip to content

Commit

Permalink
[fix] add autoCreateTooltips as a prop in AddDataToMapOptions (#2358)
Browse files Browse the repository at this point in the history
Signed-off-by: Ihor Dykhta <[email protected]>
Co-authored-by: Rui Wang <[email protected]>
  • Loading branch information
igorDykhta and albatross97 authored Oct 5, 2023
1 parent e8220b0 commit fa1edab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/reducers/src/combined-updaters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ export const isValidConfig = config =>
export const defaultAddDataToMapOptions = {
centerMap: true,
keepExistingConfig: false,
autoCreateLayers: true
autoCreateLayers: true,
autoCreateTooltips: true
};

/**
Expand Down
7 changes: 6 additions & 1 deletion src/reducers/src/vis-state-updaters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
});
Expand Down
1 change: 1 addition & 0 deletions src/types/actions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export type AddDataToMapOptions = {
readOnly?: boolean;
keepExistingConfig?: boolean;
autoCreateLayers?: boolean;
autoCreateTooltips?: boolean;
};

export type AddDataToMapPayload = {
Expand Down

0 comments on commit fa1edab

Please sign in to comment.