mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 05:55:59 +08:00
Fix/2967 (#4071)
This commit is contained in:
parent
170e5e1686
commit
6dd34a7f29
@ -1,11 +1,35 @@
|
|||||||
/* eslint-disable react/no-unstable-nested-components */
|
/* eslint-disable react/no-unstable-nested-components */
|
||||||
import type { SelectProps } from 'antd';
|
import type { SelectProps } from 'antd';
|
||||||
import { Tag } from 'antd';
|
import { Tag, Tooltip } from 'antd';
|
||||||
import { Dispatch, SetStateAction, useCallback, useMemo } from 'react';
|
import { BaseOptionType } from 'antd/es/select';
|
||||||
|
import { Dispatch, SetStateAction, useCallback, useMemo, useRef } from 'react';
|
||||||
import { Alerts } from 'types/api/alerts/getTriggered';
|
import { Alerts } from 'types/api/alerts/getTriggered';
|
||||||
|
|
||||||
import { Container, Select } from './styles';
|
import { Container, Select } from './styles';
|
||||||
|
|
||||||
|
function TextOverflowTooltip({
|
||||||
|
option,
|
||||||
|
}: {
|
||||||
|
option: BaseOptionType;
|
||||||
|
}): JSX.Element {
|
||||||
|
const contentRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
const isOverflow = contentRef.current
|
||||||
|
? contentRef.current?.offsetWidth < contentRef.current?.scrollWidth
|
||||||
|
: false;
|
||||||
|
return (
|
||||||
|
<Tooltip
|
||||||
|
placement="left"
|
||||||
|
title={option.value}
|
||||||
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||||
|
{...(!isOverflow ? { open: false } : {})}
|
||||||
|
>
|
||||||
|
<div className="ant-select-item-option-content" ref={contentRef}>
|
||||||
|
{option.value}
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function Filter({
|
function Filter({
|
||||||
setSelectedFilter,
|
setSelectedFilter,
|
||||||
setSelectedGroup,
|
setSelectedGroup,
|
||||||
@ -51,6 +75,7 @@ function Filter({
|
|||||||
|
|
||||||
const options = uniqueLabels.map((e) => ({
|
const options = uniqueLabels.map((e) => ({
|
||||||
value: e,
|
value: e,
|
||||||
|
title: '',
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const getTags: SelectProps['tagRender'] = (props): JSX.Element => {
|
const getTags: SelectProps['tagRender'] = (props): JSX.Element => {
|
||||||
@ -88,6 +113,9 @@ function Filter({
|
|||||||
placeholder="Group by any tag"
|
placeholder="Group by any tag"
|
||||||
tagRender={(props): JSX.Element => getTags(props)}
|
tagRender={(props): JSX.Element => getTags(props)}
|
||||||
options={options}
|
options={options}
|
||||||
|
optionRender={(option): JSX.Element => (
|
||||||
|
<TextOverflowTooltip option={option} />
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user