Skip to content

Commit 80cab90

Browse files
angeles-mbwildemat
authored andcommitted
[SharedUX] Expand tag filter panel width to account for long tags (elastic#241828)
Closes elastic#239243 ## Summary - Expanded tag panel width based on longest tag length - Only 3 possible fixed widths: - `288px`: this is the current fixed width we have - `400px` - `512px`: accounts for the longest tag name possible (there is a 50 char limitation set [here](https://github.com/elastic/kibana/blob/896c04f7702cede9bc2c6ba387cb1c9f43f884e8/x-pack/platform/plugins/shared/saved_objects_tagging/common/validation.ts#L12)) - Took this approach to avoid directly setting a `512px` width to account for the longest tag name possible which translated into a quite large selectable which wasn't always needed. I didn't succeed at using a `maxWidth` approach for content to dictate width. - **Note for reviewer**: I don't think the simple string length calculation could affect performance even if user has a very large number of tags and I don't see any scenario where the width could "jump" once already opened (if length is calculated before hand with all available tags). If there are concerns, we could simply set a single fixed width of `512px` (same approach we had before but wider and what is currently done in Security Rules [here](https://github.com/elastic/kibana/blob/98d4a6c74f781f416a5876160ab2cdf79b4b38cf/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/rules_table_filters/tags_filter_popover.tsx#L15)). ### Testing Before: <img width="1049" height="380" alt="Screenshot 2025-11-04 at 17 07 02" src="https://github.com/user-attachments/assets/c4351ebf-75b7-498d-b965-e3cfd0cf8850" /> After: <img width="1068" height="1302" alt="Screenshot 2025-11-04 at 17 09 15" src="https://github.com/user-attachments/assets/e27c82d0-3113-4d7f-8bbb-47d60676c93b" />
1 parent 696a8b2 commit 80cab90

File tree

1 file changed

+7
-1
lines changed
  • src/platform/packages/shared/content-management/table_list_view_table/src/components

1 file changed

+7
-1
lines changed

src/platform/packages/shared/content-management/table_list_view_table/src/components/tag_filter_panel.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import type { TagOptionItem } from './use_tag_filter_panel';
3636

3737
const isMac = navigator.platform.toLowerCase().indexOf('mac') >= 0;
3838
const modifierKeyPrefix = isMac ? '⌘' : '^';
39+
const shortTagLength = 20;
40+
const mediumTagLength = 35;
3941

4042
const clearSelectionBtnCSS = css`
4143
height: auto;
@@ -82,6 +84,10 @@ export const TagFilterPanel: FC<{}> = ({}) => {
8284
clearTagSelection,
8385
} = componentContext;
8486
const isSearchVisible = options.length > 10;
87+
const longestTagLength = Math.max(0, ...options.map((option) => (option.label ?? '').length));
88+
const panelWidthFromLongestTagLength =
89+
(longestTagLength <= shortTagLength ? 18 : longestTagLength <= mediumTagLength ? 25 : 32) *
90+
euiTheme.base;
8591

8692
const searchBoxCSS = css`
8793
padding: ${euiTheme.size.s};
@@ -137,7 +143,7 @@ export const TagFilterPanel: FC<{}> = ({}) => {
137143
closePopover={closePopover}
138144
panelPaddingSize="none"
139145
anchorPosition="downCenter"
140-
panelProps={{ css: { width: euiTheme.base * 18 } }}
146+
panelProps={{ css: { width: panelWidthFromLongestTagLength } }}
141147
>
142148
<EuiPopoverTitle paddingSize="m" css={popoverTitleCSS}>
143149
<EuiFlexGroup>

0 commit comments

Comments
 (0)