Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/components/src/map-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -858,12 +858,19 @@ export default function MapContainerFactory(
getCursor?: ({isDragging}: {isDragging: boolean}) => string;
} = {};
if (primaryMap) {
extraDeckParams.getTooltip = info =>
EditorLayerUtils.getTooltip(info, {
// Omit hover updates when the pointer position is invalid, ie. over UI overlays or
// outside the map container. In those cases x/y may be < 0
extraDeckParams.getTooltip = info => {
const x = Number(info?.x);
const y = Number(info?.y);
if (Number.isNaN(x) || Number.isNaN(y) || x < 0 || y < 0) return null;

return EditorLayerUtils.getTooltip(info, {
editorMenuActive,
editor,
theme
});
};

extraDeckParams.getCursor = ({isDragging}: {isDragging: boolean}) => {
const editorCursor = EditorLayerUtils.getCursor({
Expand Down
7 changes: 7 additions & 0 deletions test/browser-headless/component/map-container-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ test('MapContainerFactory - _renderDeckOverlay', t => {
const divWrapper = instance._renderDeckOverlay(...args);
const DeckGl = divWrapper.props.children;

t.ok(typeof DeckGl.props.getTooltip === 'function', 'DeckGl should receive getTooltip prop');
t.equal(
DeckGl.props.getTooltip({x: -1, y: -1, pixel: [-1, -1]}),
null,
'getTooltip should return null for invalid hover coordinates'
);

const clickEvents = [];
const hoverEvents = [];

Expand Down