Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix(new-select): reveal truncated values and contain dropdown scroll (#13063)

Ashwin Bhatkalc407456be7dd
diff --git a/frontend/src/components/NewSelect/CustomMultiSelect.tsx b/frontend/src/components/NewSelect/CustomMultiSelect.tsx
index 57923b2165..b8bb8ed818 100644
--- a/frontend/src/components/NewSelect/CustomMultiSelect.tsx
+++ b/frontend/src/components/NewSelect/CustomMultiSelect.tsx
@@ -21,7 +21,6 @@ import { Color } from '@signozhq/design-tokens';
import { Button, Select } from 'antd';
import { Checkbox } from '@signozhq/ui/checkbox';
import { TooltipProvider, TooltipSimple } from '@signozhq/ui/tooltip';
-import { Typography } from '@signozhq/ui/typography';
import cx from 'classnames';
import TextToolTip from 'components/TextToolTip/TextToolTip';
import { SOMETHING_WENT_WRONG } from 'constants/api';
@@ -30,6 +29,7 @@ import { capitalize, isEmpty } from 'lodash-es';
import type { BaseSelectRef } from 'rc-select';
import { popupContainer } from 'utils/selectPopupContainer';
+import TruncatedTooltip from './TruncatedTooltip';
import { CustomMultiSelectProps, CustomTagProps, OptionData } from './types';
import {
ALL_SELECTED_VALUE,
@@ -729,65 +729,71 @@ const CustomMultiSelect: React.FC<CustomMultiSelectProps> = ({
};
return (
- <div
+ <TruncatedTooltip
key={option.value || `option-${index}`}
- id={optionId}
- ref={(el): void => {
- if (index !== undefined) {
- optionRefs.current[index] = el;
- }
- }}
- className={cx('option-item', {
- selected: isSelected,
- active: isActive,
- })}
- onKeyDown={(e): void => {
- if ((e.key === 'Enter' || e.key === SPACEKEY) && isActive) {
- e.stopPropagation();
- e.preventDefault();
- handleItemSelection();
- }
- }}
- onMouseEnter={(): void => {
- setActiveIndex(index ?? -1);
- setActiveChipIndex(-1); // Clear chip selection when hovering ALL option
- }}
- role="option"
- aria-selected={isSelected}
- aria-disabled={option.disabled}
- tabIndex={isActive ? 0 : -1}
+ title={String(option.label || '')}
>
- <Checkbox
- value={isSelected}
- className="option-checkbox"
- onClick={(e): void => selectFromButton(e, 'checkbox')}
- >
- <div className="option-content">
- <Typography.Text truncate={1} className="option-label-text">
- {highlightMatchedText(String(option.label || ''), searchText)}
- </Typography.Text>
- {(option.type === 'custom' || option.type === 'regex') && (
- <div className="option-badge">{capitalize(option.type)}</div>
- )}
- {option.value && ensureValidOption(option.value) && (
- <Button
- type="text"
- className="only-btn"
- onClick={(e): void => selectFromButton(e, 'option')}
- >
- {currentToggleTagValue({ option: option.value })}
- </Button>
- )}
- <Button
- type="text"
- className="toggle-btn"
+ {(textRef): JSX.Element => (
+ <div
+ id={optionId}
+ ref={(el): void => {
+ if (index !== undefined) {
+ optionRefs.current[index] = el;
+ }
+ }}
+ className={cx('option-item', {
+ selected: isSelected,
+ active: isActive,
+ })}
+ onKeyDown={(e): void => {
+ if ((e.key === 'Enter' || e.key === SPACEKEY) && isActive) {
+ e.stopPropagation();
+ e.preventDefault();
+ handleItemSelection();
+ }
+ }}
+ onMouseEnter={(): void => {
+ setActiveIndex(index ?? -1);
+ setActiveChipIndex(-1); // Clear chip selection when hovering ALL option
+ }}
+ role="option"
+ aria-selected={isSelected}
+ aria-disabled={option.disabled}
+ tabIndex={isActive ? 0 : -1}
+ >
+ <Checkbox
+ value={isSelected}
+ className="option-checkbox"
onClick={(e): void => selectFromButton(e, 'checkbox')}
>
- Toggle
- </Button>
+ <div className="option-content">
+ <span ref={textRef} className="option-label-text">
+ {highlightMatchedText(String(option.label || ''), searchText)}
+ </span>
+ {(option.type === 'custom' || option.type === 'regex') && (
+ <div className="option-badge">{capitalize(option.type)}</div>
+ )}
+ {option.value && ensureValidOption(option.value) && (
+ <Button
+ type="text"
+ className="only-btn"
+ onClick={(e): void => selectFromButton(e, 'option')}
+ >
+ {currentToggleTagValue({ option: option.value })}
+ </Button>
+ )}
+ <Button
+ type="text"
+ className="toggle-btn"
+ onClick={(e): void => selectFromButton(e, 'checkbox')}
+ >
+ Toggle
+ </Button>
+ </div>
+ </Checkbox>
</div>
- </Checkbox>
- </div>
+ )}
+ </TruncatedTooltip>
);
},
[
diff --git a/frontend/src/components/NewSelect/CustomSelect.tsx b/frontend/src/components/NewSelect/CustomSelect.tsx
index ddbe9047a6..bed0e7feac 100644
--- a/frontend/src/components/NewSelect/CustomSelect.tsx
+++ b/frontend/src/components/NewSelect/CustomSelect.tsx
@@ -16,6 +16,7 @@ import {
X,
} from '@signozhq/icons';
import { Color } from '@signozhq/design-tokens';
+import { TooltipProvider } from '@signozhq/ui/tooltip';
import { Select } from 'antd';
import cx from 'classnames';
import TextToolTip from 'components/TextToolTip';
@@ -25,6 +26,7 @@ import { capitalize, isEmpty } from 'lodash-es';
import type { BaseSelectRef } from 'rc-select';
import { popupContainer } from 'utils/selectPopupContainer';
+import TruncatedTooltip from './TruncatedTooltip';
import { CustomSelectProps, OptionData } from './types';
import {
filterOptionsBySearch,
@@ -207,41 +209,46 @@ const CustomSelect: React.FC<CustomSelectProps> = ({
const optionId = `option-${index}`;
return (
- <div
- key={option.value}
- id={optionId}
- ref={(el): void => {
- if (index !== undefined) {
- optionRefs.current[index] = el;
- }
- }}
- className={cx('option-item', {
- selected: isSelected,
- active: isActive,
- })}
- onClick={(e): void => {
- e.stopPropagation();
- handleSelection();
- }}
- onKeyDown={(e): void => {
- if (e.key === 'Enter' || e.key === SPACEKEY) {
- e.preventDefault();
- handleSelection();
- }
- }}
- onMouseEnter={(): void => setActiveOptionIndex(index || -1)}
- role="option"
- aria-selected={isSelected}
- aria-disabled={option.disabled}
- tabIndex={isActive ? 0 : -1}
- >
- <div className="option-content">
- <div>{highlightMatchedText(String(option.label || ''), searchText)}</div>
- {option.type === 'custom' && (
- <div className="option-badge">{capitalize(option.type)}</div>
- )}
- </div>
- </div>
+ <TruncatedTooltip key={option.value} title={String(option.label || '')}>
+ {(textRef): JSX.Element => (
+ <div
+ id={optionId}
+ ref={(el): void => {
+ if (index !== undefined) {
+ optionRefs.current[index] = el;
+ }
+ }}
+ className={cx('option-item', {
+ selected: isSelected,
+ active: isActive,
+ })}
+ onClick={(e): void => {
+ e.stopPropagation();
+ handleSelection();
+ }}
+ onKeyDown={(e): void => {
+ if (e.key === 'Enter' || e.key === SPACEKEY) {
+ e.preventDefault();
+ handleSelection();
+ }
+ }}
+ onMouseEnter={(): void => setActiveOptionIndex(index || -1)}
+ role="option"
+ aria-selected={isSelected}
+ aria-disabled={option.disabled}
+ tabIndex={isActive ? 0 : -1}
+ >
+ <div className="option-content">
+ <span ref={textRef} className="option-label-text">
+ {highlightMatchedText(String(option.label || ''), searchText)}
+ </span>
+ {option.type === 'custom' && (
+ <div className="option-badge">{capitalize(option.type)}</div>
+ )}
+ </div>
+ </div>
+ )}
+ </TruncatedTooltip>
);
},
[highlightMatchedText, searchText, onChange, activeOptionIndex],
@@ -702,50 +709,67 @@ const CustomSelect: React.FC<CustomSelectProps> = ({
// ===== Final Processing =====
// Apply highlight to matched text in options
- const optionsWithHighlight = useMemo(
- () =>
- options
- ?.filter((option) =>
- String(option.label || '')
- .toLowerCase()
- .includes(searchText.toLowerCase()),
- )
- ?.map((option) => ({
- ...option,
- label: highlightMatchedText(String(option.label || ''), searchText),
- })),
- [options, searchText, highlightMatchedText],
- );
+ const optionsWithHighlight = useMemo(() => {
+ const matching =
+ options?.filter((option) =>
+ String(option.label || '')
+ .toLowerCase()
+ .includes(searchText.toLowerCase()),
+ ) ?? [];
+
+ // antd shows a value with no matching option as a bare string, so keep the
+ // selected value listed to render it through the tooltip label below.
+ return (
+ isEmpty(value)
+ ? matching
+ : prioritizeOrAddOptionForSingleSelect(matching, value)
+ ).map((option) => ({
+ ...option,
+ // Rendered as the selected value in the closed control.
+ label: (
+ <TruncatedTooltip title={String(option.label || '')} side="bottom">
+ {(textRef): JSX.Element => (
+ <span ref={textRef} className="option-label-text">
+ {highlightMatchedText(String(option.label || ''), searchText)}
+ </span>
+ )}
+ </TruncatedTooltip>
+ ),
+ }));
+ }, [options, searchText, value, highlightMatchedText]);
// ===== Component Rendering =====
return (
- <Select
- ref={selectRef}
- className={cx('custom-select', className)}
- placeholder={placeholder}
- showSearch
- filterOption={false}
- onSearch={handleSearch}
- value={value}
- onChange={onChange}
- onDropdownVisibleChange={handleDropdownVisibleChange}
- open={isOpen}
- options={optionsWithHighlight}
- defaultActiveFirstOption={defaultActiveFirstOption}
- popupMatchSelectWidth={popupMatchSelectWidth}
- allowClear={allowClear ? { clearIcon } : false}
- getPopupContainer={getPopupContainer ?? popupContainer}
- suffixIcon={<ChevronDown style={{ cursor: 'default' }} size="md" />}
- dropdownRender={customDropdownRender}
- menuItemSelectedIcon={null}
- popupClassName={cx('custom-select-dropdown-container', popupClassName)}
- listHeight={300}
- placement={placement}
- optionFilterProp="label"
- notFoundContent={<div className="empty-message">{noDataMessage}</div>}
- onKeyDown={handleKeyDown}
- {...rest}
- />
+ // Self-provided so label tooltips work wherever this select is rendered.
+ <TooltipProvider>
+ <Select
+ ref={selectRef}
+ className={cx('custom-select', className)}
+ placeholder={placeholder}
+ showSearch
+ filterOption={false}
+ onSearch={handleSearch}
+ value={value}
+ onChange={onChange}
+ onDropdownVisibleChange={handleDropdownVisibleChange}
+ open={isOpen}
+ options={optionsWithHighlight}
+ defaultActiveFirstOption={defaultActiveFirstOption}
+ popupMatchSelectWidth={popupMatchSelectWidth}
+ allowClear={allowClear ? { clearIcon } : false}
+ getPopupContainer={getPopupContainer ?? popupContainer}
+ suffixIcon={<ChevronDown style={{ cursor: 'default' }} size="md" />}
+ dropdownRender={customDropdownRender}
+ menuItemSelectedIcon={null}
+ popupClassName={cx('custom-select-dropdown-container', popupClassName)}
+ listHeight={300}
+ placement={placement}
+ optionFilterProp="label"
+ notFoundContent={<div className="empty-message">{noDataMessage}</div>}
+ onKeyDown={handleKeyDown}
+ {...rest}
+ />
+ </TooltipProvider>
);
};
diff --git a/frontend/src/components/NewSelect/TruncatedTooltip.module.scss b/frontend/src/components/NewSelect/TruncatedTooltip.module.scss
new file mode 100644
index 0000000000..dd80b908f8
--- /dev/null
+++ b/frontend/src/components/NewSelect/TruncatedTooltip.module.scss
@@ -0,0 +1,4 @@
+// Above the antd select popup it is shown from.
+.tooltipContent {
+ --tooltip-z-index: 2100;
+}
diff --git a/frontend/src/components/NewSelect/TruncatedTooltip.tsx b/frontend/src/components/NewSelect/TruncatedTooltip.tsx
new file mode 100644
index 0000000000..0b51c7b4c6
--- /dev/null
+++ b/frontend/src/components/NewSelect/TruncatedTooltip.tsx
@@ -0,0 +1,41 @@
+import { ReactElement, RefObject, useRef, useState } from 'react';
+import { TooltipSimple, TooltipSimpleProps } from '@signozhq/ui/tooltip';
+
+import styles from './TruncatedTooltip.module.scss';
+
+interface TruncatedTooltipProps {
+ title: string;
+ side?: TooltipSimpleProps['side'];
+ /** Renders the trigger; attach the ref to the element that may truncate. */
+ children: (textRef: RefObject<HTMLSpanElement>) => ReactElement;
+}
+
+function TruncatedTooltip({
+ title,
+ side = 'right',
+ children,
+}: TruncatedTooltipProps): JSX.Element {
+ const textRef = useRef<HTMLSpanElement>(null);
+ const [open, setOpen] = useState(false);
+
+ const handleOpenChange = (next: boolean): void => {
+ const el = textRef.current;
+ setOpen(next && !!el && el.scrollWidth > el.clientWidth);
+ };
+
+ return (
+ <TooltipSimple
+ title={title}
+ side={side}
+ arrow
+ delayDuration={300}
+ open={open}
+ onOpenChange={handleOpenChange}
+ tooltipContentProps={{ className: styles.tooltipContent }}
+ >
+ {children(textRef)}
+ </TooltipSimple>
+ );
+}
+
+export default TruncatedTooltip;
diff --git a/frontend/src/components/NewSelect/__test__/CustomSelect.selectedTooltip.test.tsx b/frontend/src/components/NewSelect/__test__/CustomSelect.selectedTooltip.test.tsx
new file mode 100644
index 0000000000..06050d3d25
--- /dev/null
+++ b/frontend/src/components/NewSelect/__test__/CustomSelect.selectedTooltip.test.tsx
@@ -0,0 +1,34 @@
+import { act, render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+
+import CustomSelect from '../CustomSelect';
+
+const LABEL = '/oteldemo.RecommendationService/ListRecommendations';
+
+describe('CustomSelect selected value tooltip', () => {
+ beforeEach(() => {
+ jest.useFakeTimers();
+ jest.spyOn(HTMLElement.prototype, 'scrollWidth', 'get').mockReturnValue(400);
+ jest.spyOn(HTMLElement.prototype, 'clientWidth', 'get').mockReturnValue(200);
+ });
+
+ afterEach(() => {
+ jest.useRealTimers();
+ jest.restoreAllMocks();
+ });
+
+ it.each([
+ ['listed in the options', [{ label: LABEL, value: LABEL }]],
+ ['missing from the options', [{ label: 'other', value: 'other' }]],
+ ])('reveals a truncated selected value %s on hover', async (_, options) => {
+ render(<CustomSelect options={options} value={LABEL} />);
+
+ const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
+ await user.hover(screen.getByText(LABEL));
+ act(() => {
+ jest.advanceTimersByTime(500);
+ });
+
+ expect(screen.getByRole('tooltip')).toHaveTextContent(LABEL);
+ });
+});
diff --git a/frontend/src/components/NewSelect/__test__/TruncatedTooltip.test.tsx b/frontend/src/components/NewSelect/__test__/TruncatedTooltip.test.tsx
new file mode 100644
index 0000000000..f14c558dec
--- /dev/null
+++ b/frontend/src/components/NewSelect/__test__/TruncatedTooltip.test.tsx
@@ -0,0 +1,63 @@
+import { act, render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { TooltipProvider } from '@signozhq/ui/tooltip';
+
+import TruncatedTooltip from '../TruncatedTooltip';
+
+const LABEL = '/oteldemo.RecommendationService/ListRecommendations';
+
+function renderRow(scrollWidth: number, clientWidth: number): void {
+ jest
+ .spyOn(HTMLElement.prototype, 'scrollWidth', 'get')
+ .mockReturnValue(scrollWidth);
+ jest
+ .spyOn(HTMLElement.prototype, 'clientWidth', 'get')
+ .mockReturnValue(clientWidth);
+
+ render(
+ <TooltipProvider>
+ <TruncatedTooltip title={LABEL}>
+ {(textRef): JSX.Element => (
+ <div data-testid="row">
+ <span ref={textRef}>{LABEL}</span>
+ </div>
+ )}
+ </TruncatedTooltip>
+ </TooltipProvider>,
+ );
+}
+
+async function hover(element: HTMLElement): Promise<void> {
+ const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime });
+ await user.hover(element);
+ act(() => {
+ jest.advanceTimersByTime(500);
+ });
+}
+
+describe('TruncatedTooltip', () => {
+ beforeEach(() => {
+ jest.useFakeTimers();
+ });
+
+ afterEach(() => {
+ jest.useRealTimers();
+ jest.restoreAllMocks();
+ });
+
+ it('reveals truncated text when its row is hovered', async () => {
+ renderRow(400, 200);
+
+ await hover(screen.getByTestId('row'));
+
+ expect(screen.getByRole('tooltip')).toHaveTextContent(LABEL);
+ });
+
+ it('shows no tooltip when the text fits', async () => {
+ renderRow(200, 200);
+
+ await hover(screen.getByTestId('row'));
+
+ expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
+ });
+});
diff --git a/frontend/src/components/NewSelect/stories/NewSelect.stories.tsx b/frontend/src/components/NewSelect/stories/NewSelect.stories.tsx
index 48b25e23e0..ca513b2464 100644
--- a/frontend/src/components/NewSelect/stories/NewSelect.stories.tsx
+++ b/frontend/src/components/NewSelect/stories/NewSelect.stories.tsx
@@ -135,6 +135,51 @@ const LONG_LABEL_OPTION = {
value: 'checkout-payment-authorisation',
};
+/** Truncation: hovering a cut-off option reveals its full label beside the row. */
+export const TruncatedOption: Story = {
+ args: { options: [LONG_LABEL_OPTION, ...options] },
+ play: async (): Promise<void> => {
+ await userEvent.click(
+ await screen.findByRole('combobox', { name: 'Service' }),
+ );
+ await userEvent.hover(
+ await screen.findByRole('option', { name: LONG_LABEL_OPTION.label }),
+ );
+ await screen.findByRole('tooltip', { name: LONG_LABEL_OPTION.label });
+ },
+};
+
+/** Truncation: hovering a cut-off selected value reveals it in full. */
+export const TruncatedValue: Story = {
+ args: {
+ options: [LONG_LABEL_OPTION, ...options],
+ value: LONG_LABEL_OPTION.value,
+ },
+ play: async (): Promise<void> => {
+ await userEvent.hover(await screen.findByText(LONG_LABEL_OPTION.label));
+ await screen.findByRole('tooltip', { name: LONG_LABEL_OPTION.label });
+ },
+};
+
+/** Truncation: a multi-select option reveals its full label the same way. */
+export const MultiTruncatedOption: Story = {
+ render: (): JSX.Element => (
+ <CustomMultiSelect
+ aria-label="Services"
+ options={[LONG_LABEL_OPTION, ...options]}
+ />
+ ),
+ play: async (): Promise<void> => {
+ await userEvent.click(
+ await screen.findByRole('combobox', { name: 'Services' }),
+ );
+ await userEvent.hover(
+ await screen.findByRole('option', { name: LONG_LABEL_OPTION.label }),
+ );
+ await screen.findByRole('tooltip', { name: LONG_LABEL_OPTION.label });
+ },
+};
+
/**
* Every tooltip the select renders, held open: the selected chip revealing the
* option label it was cut from. Nothing bounds that label, so the chip is given
diff --git a/frontend/src/components/NewSelect/styles.scss b/frontend/src/components/NewSelect/styles.scss
index 25922b2b3f..258fe126b3 100644
--- a/frontend/src/components/NewSelect/styles.scss
+++ b/frontend/src/components/NewSelect/styles.scss
@@ -29,6 +29,13 @@ $custom-border-color: #2c3044;
background-color: var(--l2-background);
color: color-mix(in srgb, var(--border) 70%, transparent);
}
+
+ // The search input overlays the selected value; lift the value above it while
+ // closed so hovers reach its tooltip. Clicks still open the select and focus the input.
+ &:not(.ant-select-open) .ant-select-selection-item {
+ position: relative;
+ z-index: 1;
+ }
}
// Keep chip styles ONLY in the multi-select
@@ -223,6 +230,33 @@ $custom-border-color: #2c3044;
}
}
+// Ellipsized option label; also the selected value in the closed single select.
+.option-label-text {
+ display: block;
+ flex: 1 1 auto;
+ min-width: 0;
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+}
+
+// overscroll-behavior only holds on a box that overflows; a 1px sentinel past
+// the bottom makes even a short list overflow, so the wheel never scrolls the page.
+.custom-select-dropdown,
+.custom-multiselect-dropdown {
+ position: relative;
+ overscroll-behavior: contain;
+
+ &::after {
+ content: '';
+ position: absolute;
+ top: 100%;
+ left: 0;
+ width: 1px;
+ height: 1px;
+ }
+}
+
// Custom dropdown styles for single select
.custom-select-dropdown {
padding: 8px 0 0 0;