Fix Kibana crashing when resizing a tag cloud too small (#15001) (#15091)

* Don't allow d3-cloud to run on 0 size, fix #14833

* Add test that validates correct resizing
This commit is contained in:
Tim Roes 2017-11-28 10:14:15 +01:00 committed by GitHub
parent f0b5682c75
commit 0498c737cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -304,6 +304,12 @@ class TagCloud extends EventEmitter {
async _updateLayout(job) {
if (job.size[0] <= 0 || job.size[1] <= 0) {
// If either width or height isn't above 0 we don't relayout anything,
// since the d3-cloud will be stuck in an infinite loop otherwise.
return;
}
const mapSizeToFontSize = this._makeTextSizeMapper();
const tagCloudLayoutGenerator = d3TagCloud();
tagCloudLayoutGenerator.size(job.size);

View file

@ -3,6 +3,7 @@ import expect from 'expect.js';
export default function ({ getService, getPageObjects }) {
const filterBar = getService('filterBar');
const log = getService('log');
const remote = getService('remote');
const retry = getService('retry');
const PageObjects = getPageObjects(['common', 'visualize', 'header', 'settings']);
@ -72,6 +73,15 @@ export default function ({ getService, getPageObjects }) {
expect(data).to.eql([ '32,212,254,720', '21,474,836,480', '20,401,094,656', '19,327,352,832', '18,253,611,008' ]);
});
it('should still show all tags after browser was resized very small', async function () {
await remote.setWindowSize(200, 200);
await PageObjects.common.sleep(1000);
await remote.setWindowSize(1200, 800);
await PageObjects.common.sleep(1000);
const data = await PageObjects.visualize.getTextTag();
expect(data).to.eql([ '32,212,254,720', '21,474,836,480', '20,401,094,656', '19,327,352,832', '18,253,611,008' ]);
});
it('should save and load', function () {
return PageObjects.visualize.saveVisualization(vizName1)
.then(function (message) {