Skip to content

Commit

Permalink
[8.7] [Discover] Switch from "at" to "charAt" for better browser supp…
Browse files Browse the repository at this point in the history
…ort (#156474) (#156656)

# Backport

This will backport the following commits from `main` to `8.7`:
- [[Discover] Switch from "at" to "charAt" for better browser support
(#156474)](#156474)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Julia
Rechkunova","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-05-04T09:11:18Z","message":"[Discover]
Switch from \"at\" to \"charAt\" for better browser support
(#156474)\n\nFrom the community forum: users can't access Discover on
older browsers.\r\n\r\n```\r\nTypeError: t.at is not a function\r\nat
http://xxx:5601/61109/bundles/plugin/data/kibana/data.plugin.js:1:312992\r\nat
Array.forEach ()\r\nat n
(http://xxx:5601/61109/bundles/plugin/data/kibana/data.plugin.js:1:312956)\r\nat
s
(http://xxx:5601/61109/bundles/plugin/discover/kibana/discover.chunk.0.js:1:10138)\r\nat
http://xxx:5601/61109/bundles/plugin/discover/kibana/discover.chunk.0.js:1:10215\r\nat
Array.map ()\r\nat a
(http://xxx:5601/61109/bundles/plugin/discover/kibana/discover.chunk.0.js:1:10207)\r\nat
http://xxx:5601/61109/bundles/plugin/discover/kibana/discover.chunk.0.js:1:8442\r\nat
http://xxx:5601/61109/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:334:27724\r\nat
t.s._next
(http://xxx:5601/61109/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:6:33456)\r\n```\r\n\r\n-
https://discuss.elastic.co/t/update-to-8-7-0/329525\r\n-\r\nhttps://discuss.elastic.co/t/elastic-8-7-0-error-in-discover-tab/332329/2\r\n\r\n##
Summary\r\n\r\nThis PR replaces `String` `.at` usage with `.charAt` so
it does not\r\nrequire a polyfill for older
browsers.","sha":"396a2b63d461102cb312168adf9303265919c16c","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","release_note:fix","Team:DataDiscovery","v8.7.0","v8.8.0","v8.9.0"],"number":156474,"url":"https://github.com/elastic/kibana/pull/156474","mergeCommit":{"message":"[Discover]
Switch from \"at\" to \"charAt\" for better browser support
(#156474)\n\nFrom the community forum: users can't access Discover on
older browsers.\r\n\r\n```\r\nTypeError: t.at is not a function\r\nat
http://xxx:5601/61109/bundles/plugin/data/kibana/data.plugin.js:1:312992\r\nat
Array.forEach ()\r\nat n
(http://xxx:5601/61109/bundles/plugin/data/kibana/data.plugin.js:1:312956)\r\nat
s
(http://xxx:5601/61109/bundles/plugin/discover/kibana/discover.chunk.0.js:1:10138)\r\nat
http://xxx:5601/61109/bundles/plugin/discover/kibana/discover.chunk.0.js:1:10215\r\nat
Array.map ()\r\nat a
(http://xxx:5601/61109/bundles/plugin/discover/kibana/discover.chunk.0.js:1:10207)\r\nat
http://xxx:5601/61109/bundles/plugin/discover/kibana/discover.chunk.0.js:1:8442\r\nat
http://xxx:5601/61109/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:334:27724\r\nat
t.s._next
(http://xxx:5601/61109/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:6:33456)\r\n```\r\n\r\n-
https://discuss.elastic.co/t/update-to-8-7-0/329525\r\n-\r\nhttps://discuss.elastic.co/t/elastic-8-7-0-error-in-discover-tab/332329/2\r\n\r\n##
Summary\r\n\r\nThis PR replaces `String` `.at` usage with `.charAt` so
it does not\r\nrequire a polyfill for older
browsers.","sha":"396a2b63d461102cb312168adf9303265919c16c"}},"sourceBranch":"main","suggestedTargetBranches":["8.7","8.8"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/156474","number":156474,"mergeCommit":{"message":"[Discover]
Switch from \"at\" to \"charAt\" for better browser support
(#156474)\n\nFrom the community forum: users can't access Discover on
older browsers.\r\n\r\n```\r\nTypeError: t.at is not a function\r\nat
http://xxx:5601/61109/bundles/plugin/data/kibana/data.plugin.js:1:312992\r\nat
Array.forEach ()\r\nat n
(http://xxx:5601/61109/bundles/plugin/data/kibana/data.plugin.js:1:312956)\r\nat
s
(http://xxx:5601/61109/bundles/plugin/discover/kibana/discover.chunk.0.js:1:10138)\r\nat
http://xxx:5601/61109/bundles/plugin/discover/kibana/discover.chunk.0.js:1:10215\r\nat
Array.map ()\r\nat a
(http://xxx:5601/61109/bundles/plugin/discover/kibana/discover.chunk.0.js:1:10207)\r\nat
http://xxx:5601/61109/bundles/plugin/discover/kibana/discover.chunk.0.js:1:8442\r\nat
http://xxx:5601/61109/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:334:27724\r\nat
t.s._next
(http://xxx:5601/61109/bundles/kbn-ui-shared-deps-npm/kbn-ui-shared-deps-npm.dll.js:6:33456)\r\n```\r\n\r\n-
https://discuss.elastic.co/t/update-to-8-7-0/329525\r\n-\r\nhttps://discuss.elastic.co/t/elastic-8-7-0-error-in-discover-tab/332329/2\r\n\r\n##
Summary\r\n\r\nThis PR replaces `String` `.at` usage with `.charAt` so
it does not\r\nrequire a polyfill for older
browsers.","sha":"396a2b63d461102cb312168adf9303265919c16c"}}]}]
BACKPORT-->

Co-authored-by: Julia Rechkunova <[email protected]>
  • Loading branch information
kibanamachine and jughosta authored May 4, 2023
1 parent d57914e commit 10d7a5a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/plugins/data/common/search/tabify/tabify_docs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ describe('tabify_docs', () => {
_size: 12,
_score: 77,
_source: {},
invalid_meta: 'test',
},
],
},
Expand All @@ -216,7 +217,7 @@ describe('tabify_docs', () => {
},
},
},
metaFields: ['_id', '_index', '_score', '_type', '_size'],
metaFields: ['_id', '_index', '_score', '_type', '_size', 'invalid_meta'],
fieldFormats: fieldFormats as any,
});
const table = tabifyDocs(responsePlugin, dataView);
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/data/common/search/tabify/tabify_docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ export function flattenHit(hit: Hit, indexPattern?: DataView, params?: TabifyDoc

// Merge all valid meta fields into the flattened object
indexPattern?.metaFields?.forEach((fieldName) => {
const isExcludedMetaField = EXCLUDED_META_FIELDS.includes(fieldName) || fieldName.at(0) !== '_';
const isExcludedMetaField =
EXCLUDED_META_FIELDS.includes(fieldName) || fieldName.charAt(0) !== '_';
if (isExcludedMetaField) {
return;
}
Expand Down

0 comments on commit 10d7a5a

Please sign in to comment.