Skip to content

Commit d449412

Browse files
[Discover] Fix multiline display in classic table (#103499) (#104823)
* Restore CSS that broke multiline display * Add functional test Co-authored-by: Matthias Wilhelm <[email protected]>
1 parent 2e7e55c commit d449412

File tree

6 files changed

+116
-0
lines changed

6 files changed

+116
-0
lines changed

src/plugins/discover/public/application/angular/doc_table/components/table_row/_cell.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.kbnDocTableCell__dataField {
2+
white-space: pre-wrap;
3+
}
4+
15
.kbnDocTableCell__toggleDetails {
26
padding: $euiSizeXS 0 0 0!important;
37
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
import { FtrProviderContext } from '../../ftr_provider_context';
10+
11+
export default function ({ getService, getPageObjects }: FtrProviderContext) {
12+
const esArchiver = getService('esArchiver');
13+
const kibanaServer = getService('kibanaServer');
14+
const PageObjects = getPageObjects(['common', 'discover']);
15+
const find = getService('find');
16+
const log = getService('log');
17+
const retry = getService('retry');
18+
const security = getService('security');
19+
20+
describe('discover doc table newline handling', function describeIndexTests() {
21+
before(async function () {
22+
await security.testUser.setRoles(['kibana_admin', 'kibana_message_with_newline']);
23+
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/message_with_newline');
24+
await kibanaServer.uiSettings.replace({
25+
defaultIndex: 'newline-test',
26+
'doc_table:legacy': true,
27+
});
28+
await PageObjects.common.navigateToApp('discover');
29+
});
30+
after(async () => {
31+
await security.testUser.restoreDefaults();
32+
esArchiver.unload('test/functional/fixtures/es_archiver/message_with_newline');
33+
await kibanaServer.uiSettings.unset('defaultIndex');
34+
await kibanaServer.uiSettings.unset('doc_table:legacy');
35+
});
36+
37+
it('should break text on newlines', async function () {
38+
await PageObjects.discover.clickFieldListItemToggle('message');
39+
const dscTableRows = await find.allByCssSelector('.kbnDocTable__row');
40+
41+
await retry.waitFor('height of multi-line content > single-line content', async () => {
42+
const heightWithoutNewline = await dscTableRows[0].getAttribute('clientHeight');
43+
const heightWithNewline = await dscTableRows[1].getAttribute('clientHeight');
44+
log.debug(`Without newlines: ${heightWithoutNewline}, With newlines: ${heightWithNewline}`);
45+
return Number(heightWithNewline) > Number(heightWithoutNewline);
46+
});
47+
});
48+
});
49+
}

test/functional/apps/discover/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
2727
loadTestFile(require.resolve('./_discover'));
2828
loadTestFile(require.resolve('./_discover_histogram'));
2929
loadTestFile(require.resolve('./_doc_table'));
30+
loadTestFile(require.resolve('./_doc_table_newline'));
3031
loadTestFile(require.resolve('./_filter_editor'));
3132
loadTestFile(require.resolve('./_errors'));
3233
loadTestFile(require.resolve('./_field_data'));

test/functional/config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,20 @@ export default async function ({ readConfigFile }) {
247247
},
248248
kibana: [],
249249
},
250+
kibana_message_with_newline: {
251+
elasticsearch: {
252+
cluster: [],
253+
indices: [
254+
{
255+
names: ['message_with_newline'],
256+
privileges: ['read', 'view_index_metadata'],
257+
field_security: { grant: ['*'], except: [] },
258+
},
259+
],
260+
run_as: [],
261+
},
262+
kibana: [],
263+
},
250264

251265
kibana_timefield: {
252266
elasticsearch: {
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"type": "doc",
3+
"value": {
4+
"id": "index-pattern:newline-test",
5+
"index": ".kibana",
6+
"source": {
7+
"index-pattern": {
8+
"fields": "[]",
9+
"title": "newline-test"
10+
},
11+
"type": "index-pattern"
12+
}
13+
}
14+
}
15+
16+
{
17+
"type": "doc",
18+
"value": {
19+
"id": "1",
20+
"index": "newline-test",
21+
"source": {
22+
"message" : "no new line"
23+
}
24+
}
25+
}
26+
27+
{
28+
"type": "doc",
29+
"value": {
30+
"id": "2",
31+
"index": "newline-test",
32+
"source": {
33+
"message" : "two\nnew\nlines"
34+
}
35+
}
36+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"type": "index",
3+
"value": {
4+
"index": "newline-test",
5+
"settings": {
6+
"index": {
7+
"number_of_replicas": "0",
8+
"number_of_shards": "1"
9+
}
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)