Skip to content

Commit

Permalink
[fix] Prevent the app from crashing on geojson layer hover (#2087)
Browse files Browse the repository at this point in the history
  • Loading branch information
igorDykhta authored Jan 18, 2023
1 parent a66f98f commit fd3a7a8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/layers/src/geojson-layer/geojson-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,11 @@ export default class GeoJsonLayer extends Layer {

getHoverData(object, dataContainer) {
// index of dataContainer is saved to feature.properties
return dataContainer.row(object.properties.index);
const index = object?.properties?.index;
if (index >= 0) {
return dataContainer.row(index);
}
return null;
}

calculateDataAttribute({dataContainer, filteredIndex}, getPosition) {
Expand Down
3 changes: 3 additions & 0 deletions src/reducers/src/layer-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ export function getLayerHoverProp({
}
const {dataContainer, fields} = datasets[dataId];
const data: DataRow | null = layer.getHoverData(object, dataContainer, fields);
if (!data) {
return null;
}
const fieldsToShow = interactionConfig.tooltip.config.fieldsToShow[dataId];

return {
Expand Down

0 comments on commit fd3a7a8

Please sign in to comment.