diff --git a/src/core_plugins/kbn_vislib_vis_types/public/tile_map.js b/src/core_plugins/kbn_vislib_vis_types/public/tile_map.js index cb6ae028cf2b..8c2e18ed3e2b 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/tile_map.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/tile_map.js @@ -48,11 +48,17 @@ export default function TileMapVisType(Private, getAppState, courier, config) { pushFilter(filter, false, indexPatternName); }, - mapMoveEnd: function (event, uiState) { - uiState.set('mapCenter', event.center); + mapMoveEnd: function (event) { + const vis = _.get(event, 'chart.geohashGridAgg.vis'); + if (vis && vis.hasUiState()) { + vis.getUiState().set('mapCenter', event.center); + } }, - mapZoomEnd: function (event, uiState) { - uiState.set('mapZoom', event.zoom); + mapZoomEnd: function (event) { + const vis = _.get(event, 'chart.geohashGridAgg.vis'); + if (vis && vis.hasUiState()) { + vis.getUiState().set('mapZoom', event.zoom); + } const autoPrecision = _.get(event, 'chart.geohashGridAgg.params.autoPrecision'); if (autoPrecision) { diff --git a/src/ui/public/vislib/__tests__/lib/handler/handler.js b/src/ui/public/vislib/__tests__/lib/handler/handler.js index ea933bf8d89e..6953e3ebef2e 100644 --- a/src/ui/public/vislib/__tests__/lib/handler/handler.js +++ b/src/ui/public/vislib/__tests__/lib/handler/handler.js @@ -134,5 +134,27 @@ dateHistogramArray.forEach(function (data, i) { expect(vis.handler.charts.length).to.be(0); }); }); + + describe('event proxying', function () { + + it('should only pass the original event object to downstream handlers', function (done) { + const event = {}; + const chart = vis.handler.charts[0]; + + const mockEmitter = function () { + const args = Array.from(arguments); + expect(args.length).to.be(2); + expect(args[0]).to.be('click'); + expect(args[1]).to.be(event); + done(); + }; + + vis.emit = mockEmitter; + vis.handler.enable('click', chart); + chart.events.emit('click', event); + }); + + }); + }); }); diff --git a/src/ui/public/vislib/lib/handler/handler.js b/src/ui/public/vislib/lib/handler/handler.js index e496c1b39271..a74c62793186 100644 --- a/src/ui/public/vislib/lib/handler/handler.js +++ b/src/ui/public/vislib/lib/handler/handler.js @@ -55,7 +55,7 @@ export default function HandlerBaseClass(Private) { this.getProxyHandler = _.memoize(function (event) { let self = this; return function (e) { - self.vis.emit(event, e, vis.uiState); + self.vis.emit(event, e); }; }); }