Skip to content

Commit 7458bb6

Browse files
[9.1] [Discover] Fix issue with actions column header size (#235227) (#235326)
# Backport This will backport the following commits from `main` to `9.1`: - [[Discover] Fix issue with actions column header size (#235227)](#235227) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Miłosz Radzyński","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-09-17T08:50:11Z","message":"[Discover] Fix issue with actions column header size (#235227)\n\n## Summary\n\nThis PR fixes the bug with showing \"Actions\" header column name even if\nthere was no space and info icon would fit better.\nIt uses the EuiResizeObserver to get the dimentions of the action column\nand decide if we should show icon or full text.\nResolves: #234647\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [ ] 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- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"462538530236ff5d82dde0179c829761d6b86923","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:DataDiscovery","backport:version","v9.2.0","v8.18.8","v8.19.5","v9.0.8","v9.1.5"],"title":"[Discover] Fix issue with actions column header size","number":235227,"url":"https://github.com/elastic/kibana/pull/235227","mergeCommit":{"message":"[Discover] Fix issue with actions column header size (#235227)\n\n## Summary\n\nThis PR fixes the bug with showing \"Actions\" header column name even if\nthere was no space and info icon would fit better.\nIt uses the EuiResizeObserver to get the dimentions of the action column\nand decide if we should show icon or full text.\nResolves: #234647\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [ ] 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- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"462538530236ff5d82dde0179c829761d6b86923"}},"sourceBranch":"main","suggestedTargetBranches":["8.18","8.19","9.0","9.1"],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/235227","number":235227,"mergeCommit":{"message":"[Discover] Fix issue with actions column header size (#235227)\n\n## Summary\n\nThis PR fixes the bug with showing \"Actions\" header column name even if\nthere was no space and info icon would fit better.\nIt uses the EuiResizeObserver to get the dimentions of the action column\nand decide if we should show icon or full text.\nResolves: #234647\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [ ] 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- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"462538530236ff5d82dde0179c829761d6b86923"}},{"branch":"8.18","label":"v8.18.8","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.5","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.8","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.1","label":"v9.1.5","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Miłosz Radzyński <[email protected]>
1 parent 9710fb8 commit 7458bb6

File tree

1 file changed

+31
-23
lines changed
  • src/platform/packages/shared/kbn-unified-data-table/src/components/custom_control_columns/actions_column

1 file changed

+31
-23
lines changed

src/platform/packages/shared/kbn-unified-data-table/src/components/custom_control_columns/actions_column/actions_header.tsx

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,28 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
import React, { useLayoutEffect, useRef, useState } from 'react';
11-
import { EuiIconTip, EuiScreenReaderOnly } from '@elastic/eui';
10+
import React, { useCallback, useState } from 'react';
11+
import {
12+
type EuiResizeObserverProps,
13+
EuiIconTip,
14+
EuiResizeObserver,
15+
EuiScreenReaderOnly,
16+
} from '@elastic/eui';
1217
import { css } from '@emotion/react';
1318
import { i18n } from '@kbn/i18n';
1419
import ColumnHeaderTruncateContainer from '../../column_header_truncate_container';
1520

1621
export const ActionsHeader = ({ maxWidth }: { maxWidth: number }) => {
17-
const textRef = useRef<HTMLSpanElement>(null);
1822
const [showText, setShowText] = useState(false);
1923

20-
useLayoutEffect(() => {
21-
if (!textRef.current) return;
22-
const textWidth = textRef.current.getBoundingClientRect().width;
23-
setShowText(textWidth < maxWidth);
24-
}, [textRef, maxWidth, setShowText]);
24+
const measure: EuiResizeObserverProps['onResize'] = useCallback(
25+
(dimensions) => {
26+
if (!dimensions) return;
27+
28+
setShowText(dimensions.width < maxWidth);
29+
},
30+
[maxWidth]
31+
);
2532

2633
const actionsText = i18n.translate('unifiedDataTable.controlColumnsActionHeader', {
2734
defaultMessage: 'Actions',
@@ -40,25 +47,26 @@ export const ActionsHeader = ({ maxWidth }: { maxWidth: number }) => {
4047
<span data-test-subj="unifiedDataTable_actionsColumnHeaderText">{actionsText}</span>
4148
) : (
4249
<EuiIconTip
43-
iconProps={{
44-
'data-test-subj': 'unifiedDataTable_actionsColumnHeaderIcon',
45-
}}
50+
iconProps={{ 'data-test-subj': 'unifiedDataTable_actionsColumnHeaderIcon' }}
4651
type="info"
4752
content={actionsText}
4853
/>
4954
)}
50-
{/* Hidden measurement span */}
51-
<span
52-
ref={textRef}
53-
css={css`
54-
position: absolute;
55-
visibility: hidden;
56-
white-space: nowrap;
57-
pointer-events: none;
58-
`}
59-
>
60-
{actionsText}
61-
</span>
55+
<EuiResizeObserver onResize={measure}>
56+
{(resizeRef) => (
57+
<span
58+
ref={resizeRef}
59+
css={css`
60+
position: absolute;
61+
visibility: hidden;
62+
white-space: nowrap;
63+
pointer-events: none;
64+
`}
65+
>
66+
{actionsText}
67+
</span>
68+
)}
69+
</EuiResizeObserver>
6270
</ColumnHeaderTruncateContainer>
6371
);
6472
};

0 commit comments

Comments
 (0)