Skip to content

Commit

Permalink
Merge pull request elastic#7793 from Bargs/visFilterFix
Browse files Browse the repository at this point in the history
Fix filtering from visualizations

Former-commit-id: 287cf99
  • Loading branch information
Matt Bargar authored Jul 22, 2016
2 parents 4921bdd + 1c8890f commit 321035a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/core_plugins/kbn_vislib_vis_types/public/tile_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
22 changes: 22 additions & 0 deletions src/ui/public/vislib/__tests__/lib/handler/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

});

});
});
2 changes: 1 addition & 1 deletion src/ui/public/vislib/lib/handler/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
});
}
Expand Down

0 comments on commit 321035a

Please sign in to comment.