Skip to content

Commit f4b3dea

Browse files
[9.1] Fix: Add styling to handle the text overflow (elastic#239768) (elastic#240084)
# Backport This will backport the following commits from `main` to `9.1`: - [Fix: Add styling to handle the text overflow (elastic#239768)](elastic#239768) <!--- Backport version: 10.1.0 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Efe Gürkan YALAMAN","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-10-22T10:51:19Z","message":"Fix: Add styling to handle the text overflow (elastic#239768)\n\n## Summary\n\nThis fixes a case where having too long id not wrapping and overflowing\nthe popout by truncating the text and adding a copy button with tooltip\nto show whole ID.\n\nBefore\n<img width=\"3192\" height=\"954\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/84eb8772-a4ab-4310-b6f3-c1973b91948d\"\n/>\n\nAfter\n<img width=\"341\" height=\"218\" alt=\"Screenshot 2025-10-16 at 20 15 19\"\nsrc=\"https://github.com/user-attachments/assets/b1dad5d6-3123-4710-baf6-3c362cfa2580\"\n/>\n<img width=\"367\" height=\"234\" alt=\"Screenshot 2025-10-16 at 20 15 23\"\nsrc=\"https://github.com/user-attachments/assets/44606124-57b1-4a86-8071-89bca85860b9\"\n/>\n\n\n\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [x] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n~[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials~\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] ~If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)~\n- [ ] ~This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.~\n- [ ] ~[Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed~\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [ ] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.\n\n\n## Release Note:\nFixed data preview metadata popup visual issues when ID is too long.\nAdded a tooltip and copy button to improve user experience.\n\nCo-authored-by: Elastic Machine <[email protected]>","sha":"32972ca0ca2409a6b1c0a1dd7c0a499dbfae9401","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Search","backport:version","v9.2.0","v9.3.0","v9.1.6","v8.19.6"],"title":"Fix: Add styling to handle the text overflow","number":239768,"url":"https://github.com/elastic/kibana/pull/239768","mergeCommit":{"message":"Fix: Add styling to handle the text overflow (elastic#239768)\n\n## Summary\n\nThis fixes a case where having too long id not wrapping and overflowing\nthe popout by truncating the text and adding a copy button with tooltip\nto show whole ID.\n\nBefore\n<img width=\"3192\" height=\"954\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/84eb8772-a4ab-4310-b6f3-c1973b91948d\"\n/>\n\nAfter\n<img width=\"341\" height=\"218\" alt=\"Screenshot 2025-10-16 at 20 15 19\"\nsrc=\"https://github.com/user-attachments/assets/b1dad5d6-3123-4710-baf6-3c362cfa2580\"\n/>\n<img width=\"367\" height=\"234\" alt=\"Screenshot 2025-10-16 at 20 15 23\"\nsrc=\"https://github.com/user-attachments/assets/44606124-57b1-4a86-8071-89bca85860b9\"\n/>\n\n\n\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [x] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n~[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials~\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] ~If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)~\n- [ ] ~This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.~\n- [ ] ~[Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed~\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [ ] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.\n\n\n## Release Note:\nFixed data preview metadata popup visual issues when ID is too long.\nAdded a tooltip and copy button to improve user experience.\n\nCo-authored-by: Elastic Machine <[email protected]>","sha":"32972ca0ca2409a6b1c0a1dd7c0a499dbfae9401"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"9.2","label":"v9.2.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/240058","number":240058,"state":"OPEN"},{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/239768","number":239768,"mergeCommit":{"message":"Fix: Add styling to handle the text overflow (elastic#239768)\n\n## Summary\n\nThis fixes a case where having too long id not wrapping and overflowing\nthe popout by truncating the text and adding a copy button with tooltip\nto show whole ID.\n\nBefore\n<img width=\"3192\" height=\"954\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/84eb8772-a4ab-4310-b6f3-c1973b91948d\"\n/>\n\nAfter\n<img width=\"341\" height=\"218\" alt=\"Screenshot 2025-10-16 at 20 15 19\"\nsrc=\"https://github.com/user-attachments/assets/b1dad5d6-3123-4710-baf6-3c362cfa2580\"\n/>\n<img width=\"367\" height=\"234\" alt=\"Screenshot 2025-10-16 at 20 15 23\"\nsrc=\"https://github.com/user-attachments/assets/44606124-57b1-4a86-8071-89bca85860b9\"\n/>\n\n\n\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [x] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [ ]\n~[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas added for features that require explanation or tutorials~\n- [ ] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [ ] ~If a plugin configuration key changed, check if it needs to be\nallowlisted in the cloud and added to the [docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)~\n- [ ] ~This was checked for breaking HTTP API changes, and any breaking\nchanges have been approved by the breaking-change committee. The\n`release_note:breaking` label should be applied in these situations.~\n- [ ] ~[Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed~\n- [ ] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n- [ ] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.\n\n\n## Release Note:\nFixed data preview metadata popup visual issues when ID is too long.\nAdded a tooltip and copy button to improve user experience.\n\nCo-authored-by: Elastic Machine <[email protected]>","sha":"32972ca0ca2409a6b1c0a1dd7c0a499dbfae9401"}},{"branch":"9.1","label":"v9.1.6","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.6","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: Elastic Machine <[email protected]>
1 parent 2001630 commit f4b3dea

File tree

2 files changed

+70
-3
lines changed

2 files changed

+70
-3
lines changed

x-pack/platform/packages/shared/kbn-search-index-documents/components/result/rich_result_header.tsx

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ import {
2323
EuiTitle,
2424
useEuiTheme,
2525
EuiToolTip,
26+
copyToClipboard,
2627
} from '@elastic/eui';
2728

2829
import { i18n } from '@kbn/i18n';
2930
import { css } from '@emotion/react';
3031
import { FormattedMessage } from '@kbn/i18n-react';
31-
import { MetaDataProps } from './result_types';
32+
33+
import type { MetaDataProps } from './result_types';
34+
import { definitionStyle } from './styles';
3235

3336
interface Props {
3437
metaData: MetaDataProps;
@@ -52,9 +55,58 @@ const Term: React.FC<TermDef> = ({ label }) => (
5255

5356
const Definition: React.FC<TermDef> = ({ label }) => (
5457
<EuiFlexItem>
55-
<EuiTextColor color="subdued">{label}</EuiTextColor>
58+
<EuiToolTip position="top" content={label}>
59+
<EuiTextColor component="div" css={definitionStyle} color="subdued">
60+
{label}
61+
</EuiTextColor>
62+
</EuiToolTip>
5663
</EuiFlexItem>
5764
);
65+
const CopyButton: React.FC<{ textToCopy: string }> = ({ textToCopy }) => {
66+
const [isTextCopied, setTextCopied] = useState(false);
67+
68+
const onClick = () => {
69+
copyToClipboard(textToCopy);
70+
setTextCopied(true);
71+
};
72+
const onBlur = () => {
73+
setTextCopied(false);
74+
};
75+
return (
76+
<EuiToolTip
77+
content={
78+
isTextCopied
79+
? i18n.translate(
80+
'xpack.searchIndexDocuments.result.header.compactCard.metadata.copiedTextToClipboard',
81+
{
82+
defaultMessage: 'Copied to clipboard',
83+
}
84+
)
85+
: i18n.translate(
86+
'xpack.searchIndexDocuments.result.header.compactCard.metadata.copyTextToClipboard',
87+
{
88+
defaultMessage: 'Copy text to clipboard',
89+
}
90+
)
91+
}
92+
data-test-subj="copyTextToClipboardButtonTooltip"
93+
>
94+
<EuiButtonIcon
95+
aria-label={i18n.translate(
96+
'xpack.searchIndexDocuments.result.header.compactCard.metadata.copyTextToClipboard',
97+
{
98+
defaultMessage: 'Copy text to clipboard',
99+
}
100+
)}
101+
data-test-subj="copyTextToClipboardButton"
102+
color="text"
103+
iconType="copy"
104+
onClick={onClick}
105+
onBlur={onBlur}
106+
/>
107+
</EuiToolTip>
108+
);
109+
};
58110
const MetadataPopover: React.FC<MetaDataProps> = ({
59111
id,
60112
onDocumentDelete,
@@ -102,9 +154,10 @@ const MetadataPopover: React.FC<MetaDataProps> = ({
102154
`}
103155
>
104156
<EuiFlexItem>
105-
<EuiFlexGroup justifyContent="spaceBetween" gutterSize="s">
157+
<EuiFlexGroup justifyContent="spaceBetween" gutterSize="s" alignItems="center">
106158
<Term label="ID" />
107159
<Definition label={id} />
160+
<CopyButton textToCopy={id} />
108161
</EuiFlexGroup>
109162
</EuiFlexItem>
110163

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { css } from '@emotion/react';
9+
10+
export const definitionStyle = css({
11+
textOverflow: 'ellipsis',
12+
overflow: 'hidden',
13+
maxWidth: '16rem',
14+
});

0 commit comments

Comments
 (0)