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.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
feat(quick-filters): section hover actions + duration reset (UX) (#12760)
Aditya Singh2387266df57f
diff --git a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/checkboxFilterQuery.test.ts b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/checkboxFilterQuery.test.tsindex bff4e46084..84e26e75aa 100644--- a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/checkboxFilterQuery.test.ts+++ b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/checkboxFilterQuery.test.ts@@ -11,10 +11,10 @@ import {import {applyCheckboxToggle,- clearFilterFromQuery,deriveCheckboxState,getNotInOperator,} from './checkboxFilterQuery';+import { clearFilterFromQuery } from '../shared/filterQuery';import { CheckedState } from '../../types';import { SectionType } from './v2/itemRules';@@ -505,7 +505,7 @@ describe('clearFilterFromQuery', () => {const result = clearFilterFromQuery({currentQuery: query,- filter: { attributeKey: { key: KEY, type: 'tag' } } as never,+ filterKey: KEY,activeQueryIndex: 0,});@@ -523,4 +523,35 @@ describe('clearFilterFromQuery', () => {expect(other.filters?.items).toHaveLength(1);expect(other.filter?.expression).toBe(`${KEY} = 'a'`);});++ it('without an operators list, clears non-managed clauses too (duration >= / <=)', () => {+ const query = {+ builder: {+ queryData: [+ {+ filters: {+ items: [+ toTagItem({ key: 'durationNano', op: '>=', value: 5000000 }, 0),+ toTagItem({ key: 'durationNano', op: '<=', value: 9000000 }, 1),+ ],+ op: 'AND',+ },+ filter: {+ expression: `durationNano >= 5000000 AND durationNano <= 9000000 AND http.method = 'GET'`,+ },+ },+ ],+ },+ } as unknown as Query;++ const result = clearFilterFromQuery({+ currentQuery: query,+ filterKey: 'durationNano',+ activeQueryIndex: 0,+ });++ const active = result.builder.queryData[0];+ expect(active.filters?.items).toStrictEqual([]);+ expect(active.filter?.expression).toBe(`http.method = 'GET'`);+ });});diff --git a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/checkboxFilterQuery.ts b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/checkboxFilterQuery.tsindex 1fc1a2d62d..d0c9e207ed 100644--- a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/checkboxFilterQuery.ts+++ b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/checkboxFilterQuery.ts@@ -23,7 +23,12 @@ export const NON_SELECTED_OPERATORS = [OPERATORS['!='], 'not in', 'nin'];// The operators this algebra emits, and so the only ones it may rewrite out of an// expression. A hand-written clause on the same key (CONTAINS, EXISTS, a range) is// none of its business and has to survive a toggle.-const MANAGED_OPERATORS = [OPERATORS['='], OPERATORS['!='], 'in', 'not in'];+export const MANAGED_OPERATORS = [+ OPERATORS['='],+ OPERATORS['!='],+ 'in',+ 'not in',+];/*** Drops this filter's own clauses for `key` from `expression`, leaving every other@@ -31,7 +36,7 @@ const MANAGED_OPERATORS = [OPERATORS['='], OPERATORS['!='], 'in', 'not in'];* prefixes, since `isKeyMatch` treats `service.name` and `resource.service.name` as* the same filter but expression rewrites match keys literally.*/-function removeManagedClauses(expression: string, key: string): string {+export function removeManagedClauses(expression: string, key: string): string {return removeKeysFromExpression(expression,getKeySpellings(key),@@ -124,49 +129,6 @@ export function deriveCheckboxState({return filterState;}-/**- * Returns a new query with this filter's clauses for the attribute key removed from- * the active query, both from the structured filter items and the raw expression.- */-export function clearFilterFromQuery({- currentQuery,- filter,- activeQueryIndex,-}: {- currentQuery: Query;- filter: IQuickFiltersConfig;- activeQueryIndex: number;-}): Query {- return {- ...currentQuery,- builder: {- ...currentQuery.builder,- queryData: currentQuery.builder.queryData.map((item, idx) => {- if (idx !== activeQueryIndex) {- return item;- }- return {- ...item,- filter: {- expression: removeManagedClauses(- item.filter?.expression ?? '',- filter.attributeKey.key,- ),- },- filters: {- ...item.filters,- items:- item.filters?.items?.filter(- (fil) => !isKeyMatch(fil.key?.key, filter.attributeKey.key),- ) || [],- op: item.filters?.op || 'AND',- },- };- }),- },- };-}-// eslint-disable-next-line sonarjs/cognitive-complexityexport function applyCheckboxToggle({currentQuery,diff --git a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/useCheckboxFilterActions.ts b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/useCheckboxFilterActions.tsindex fe92530e80..ef0577edb1 100644--- a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/useCheckboxFilterActions.ts+++ b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/useCheckboxFilterActions.ts@@ -4,13 +4,11 @@ import {QuickFiltersSource,} from 'components/QuickFilters/types';import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';-import { isFunction } from 'lodash-es';+import { isEqual, isFunction } from 'lodash-es';import { Query } from 'types/api/queryBuilder/queryBuilderData';-import {- applyCheckboxToggle,- clearFilterFromQuery,-} from './checkboxFilterQuery';+import { applyCheckboxToggle, MANAGED_OPERATORS } from './checkboxFilterQuery';+import { clearFilterFromQuery } from '../shared/filterQuery';import { CheckedState } from '../../types';import { SectionType } from './v2/itemRules';@@ -94,7 +92,17 @@ function useCheckboxFilterActions({};const onClear = (): void => {- dispatch(clearFilterFromQuery({ currentQuery, filter, activeQueryIndex }));+ const clearedQuery = clearFilterFromQuery({+ currentQuery,+ filterKey: filter.attributeKey.key,+ activeQueryIndex,+ operators: MANAGED_OPERATORS,+ });+ // Nothing to clear; no dispatch+ if (isEqual(clearedQuery, currentQuery)) {+ return;+ }+ dispatch(clearedQuery);};return { onChange, onClear };diff --git a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/CheckboxFilterV2.module.scss b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/CheckboxFilterV2.module.scssindex 7567b88fbe..eaeb60a44f 100644--- a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/CheckboxFilterV2.module.scss+++ b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/CheckboxFilterV2.module.scss@@ -6,6 +6,44 @@border-bottom: 1px solid var(--l1-border);}+.sectionActions {+ width: 0;+ overflow: hidden;+ opacity: 0;+ transform: translateX(4px);+ pointer-events: none;+ transition:+ opacity 0.16s ease,+ transform 0.16s ease,+ width 0s linear 0.16s;+}++.checkboxFilter:hover .sectionActions,+.sectionActions.sectionActionsPinned {+ width: auto;+ opacity: 1;+ transform: translateX(0);+ pointer-events: auto;+ transition:+ opacity 0.16s ease,+ transform 0.16s ease;+}++.sectionActionsPinned .sectionActionHoverOnly {+ opacity: 0;+ transform: translateX(4px);+ pointer-events: none;+ transition:+ opacity 0.16s ease,+ transform 0.16s ease;+}++.checkboxFilter:hover .sectionActionsPinned .sectionActionHoverOnly {+ opacity: 1;+ transform: translateX(0);+ pointer-events: auto;+}+.search {--input-background: var(--l2-background);--input-hover-background: var(--l2-background);diff --git a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/CheckboxFilterV2.tsx b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/CheckboxFilterV2.tsxindex e4ca7794f2..e634a6577f 100644--- a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/CheckboxFilterV2.tsx+++ b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/CheckboxFilterV2.tsx@@ -1,6 +1,7 @@import { useEffect, useMemo, useRef, useState } from 'react';import { Input } from '@signozhq/ui/input';import { Skeleton } from 'antd';+import classNames from 'classnames';import { Typography } from '@signozhq/ui/typography';import { LoaderCircle } from '@signozhq/icons';import {@@ -44,8 +45,14 @@ export default function CheckboxFilterV2(const { source, filter, onFilterChange, onQuickFilterChange, useFieldApis } =props;const [searchText, setSearchText] = useState<string>('');+ const [isSearchOpen, setIsSearchOpen] = useState<boolean>(false);const [userToggleState, setUserToggleState] = useState<boolean | null>(null);+ const handleToggleSearch = (): void => {+ setIsSearchOpen((prev) => !prev);+ setSearchText('');+ };+const { currentQuery } = useQueryBuilder();const activeQueryIndex = useActiveQueryIndex(source);@@ -164,12 +171,15 @@ export default function CheckboxFilterV2(<CheckboxFilterV2Headertitle={filter.title}isOpen={isOpen}- showClearAll={!!attributeValues.length}+ actionsClassName={classNames(styles.sectionActions, {+ [styles.sectionActionsPinned]: isSearchOpen,+ })}+ resetActionClassName={+ isSearchOpen ? styles.sectionActionHoverOnly : undefined+ }onToggleOpen={onToggleOpen}+ onToggleSearch={handleToggleSearch}onClear={onClear}- isSomeFilterPresentForCurrentAttribute={- isSomeFilterPresentForCurrentAttribute- }/>{isOpen && isLoading && !hasLoadedOnce.current && (<section>@@ -178,23 +188,26 @@ export default function CheckboxFilterV2()}{isOpen && (!isLoading || hasLoadedOnce.current) && (<>- <section className={styles.search}>- <Input- placeholder="Filter values"- onChange={(e): void => setSearchTextDebounced(e.target.value)}- disabled={isFilterDisabled}- data-testid="checkbox-filter-search"- suffix={- isFetching ? (- <LoaderCircle- size={14}- className={styles.searchSpinner}- data-testid="checkbox-filter-search-loading"- />- ) : null- }- />- </section>+ {isSearchOpen && (+ <section className={styles.search}>+ <Input+ autoFocus+ placeholder="Filter values"+ onChange={(e): void => setSearchTextDebounced(e.target.value)}+ disabled={isFilterDisabled}+ data-testid="checkbox-filter-search"+ suffix={+ isFetching ? (+ <LoaderCircle+ size={14}+ className={styles.searchSpinner}+ data-testid="checkbox-filter-search-loading"+ />+ ) : null+ }+ />+ </section>+ )}{totalCount > 0 && (<section className={styles.values}>diff --git a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/CheckboxFilterV2Header.module.scss b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/CheckboxFilterV2Header.module.scssindex 52a74b593f..2087677afd 100644--- a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/CheckboxFilterV2Header.module.scss+++ b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/CheckboxFilterV2Header.module.scss@@ -3,12 +3,20 @@align-items: center;justify-content: space-between;cursor: pointer;+ gap: var(--spacing-2);}.leftAction {display: flex;align-items: center;gap: var(--spacing-3);+ flex: 1 1 auto;+ min-width: 0;++ // The collapse chevron must keep its size; only the title absorbs the squeeze.+ > svg {+ flex-shrink: 0;+ }}.title {@@ -18,16 +26,18 @@line-height: 18px;letter-spacing: -0.07px;text-transform: capitalize;+ // Always ellipsize a long name; on hover the actions take width and it+ // compresses further.+ flex: 1 1 auto;+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;}.rightAction {display: flex;align-items: center;- min-width: 48px;-}--.clearAll {- font-size: 12px;- color: var(--accent-primary);- cursor: pointer;+ gap: var(--spacing-1);+ flex-shrink: 0;}diff --git a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/CheckboxFilterV2Header.tsx b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/CheckboxFilterV2Header.tsxindex 352e9b2fe5..f56b871203 100644--- a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/CheckboxFilterV2Header.tsx+++ b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/CheckboxFilterV2Header.tsx@@ -1,25 +1,47 @@+import { useState } from 'react';+import { TooltipSimple } from '@signozhq/ui/tooltip';import { Typography } from '@signozhq/ui/typography';-import { ChevronDown, ChevronRight } from '@signozhq/icons';+import { ChevronDown, ChevronRight, Search, Undo2 } from '@signozhq/icons';++import { SectionActionButton } from '../../shared/SectionActionButton/SectionActionButton';++import classNames from 'classnames';import styles from './CheckboxFilterV2Header.module.scss';interface CheckboxFilterHeaderProps {title: string;isOpen: boolean;- showClearAll: boolean;+ actionsClassName?: string;+ resetActionClassName?: string;onToggleOpen: () => void;+ onToggleSearch: () => void;onClear: () => void;- isSomeFilterPresentForCurrentAttribute: boolean;}export function CheckboxFilterV2Header({title,isOpen,- showClearAll,+ actionsClassName,+ resetActionClassName,onToggleOpen,+ onToggleSearch,onClear,- isSomeFilterPresentForCurrentAttribute,}: CheckboxFilterHeaderProps): JSX.Element {+ const [isTitleTruncated, setIsTitleTruncated] = useState(false);++ const measureTitle = (el: HTMLElement | null): void => {+ if (el) {+ setIsTitleTruncated(el.scrollWidth > el.clientWidth);+ }+ };++ const titleText = (+ <Typography.Text ref={measureTitle} className={styles.title}>+ {title}+ </Typography.Text>+ );+return (<sectionrole="button"@@ -40,23 +62,31 @@ export function CheckboxFilterV2Header({) : (<ChevronRight size={13} cursor="pointer" />)}- <Typography.Text className={styles.title}>{title}</Typography.Text>- </section>- <section className={styles.rightAction}>- {isOpen && showClearAll && isSomeFilterPresentForCurrentAttribute && (- <Typography.Text- className={styles.clearAll}- onClick={(e): void => {- e.stopPropagation();- e.preventDefault();- onClear();- }}- data-testid="checkbox-filter-clear-all"- >- Clear- </Typography.Text>+ {isTitleTruncated ? (+ <TooltipSimple title={title} delayDuration={400}>+ {titleText}+ </TooltipSimple>+ ) : (+ titleText)}</section>+ {isOpen && (+ <section className={classNames(styles.rightAction, actionsClassName)}>+ <SectionActionButton+ icon={<Undo2 size={14} />}+ className={resetActionClassName}+ tooltip="Reset"+ onClick={onClear}+ testId="checkbox-filter-clear-all"+ />+ <SectionActionButton+ icon={<Search size={14} />}+ tooltip="Search"+ onClick={onToggleSearch}+ testId="checkbox-filter-search-toggle"+ />+ </section>+ )}</section>);}diff --git a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/__tests__/CheckboxFilterV2.interactions.test.tsx b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/__tests__/CheckboxFilterV2.interactions.test.tsxindex 3615301dee..854016386f 100644--- a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/__tests__/CheckboxFilterV2.interactions.test.tsx+++ b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/__tests__/CheckboxFilterV2.interactions.test.tsx@@ -60,6 +60,7 @@ describe('CheckboxFilterV2 - interactions', () => {await screen.findByTestId('checkbox-value-row-production');expect(screen.getByTestId('checkbox-value-row-staging')).toBeInTheDocument();+ await user.click(screen.getByTestId('checkbox-filter-search-toggle'));const searchInput = screen.getByTestId('checkbox-filter-search');await user.type(searchInput, 'prod');@@ -143,6 +144,7 @@ describe('CheckboxFilterV2 - interactions', () => {// Related values now appear in "Related" section (no badge, uses divider instead)expect(screen.getByTestId('section-divider-related')).toBeInTheDocument();+ await user.click(screen.getByTestId('checkbox-filter-search-toggle'));const searchInput = screen.getByTestId('checkbox-filter-search');await user.type(searchInput, 'prod');@@ -192,6 +194,7 @@ describe('CheckboxFilterV2 - interactions', () => {await screen.findByTestId('checkbox-value-row-prod');+ await user.click(screen.getByTestId('checkbox-filter-search-toggle'));const searchInput = screen.getByTestId('checkbox-filter-search');await user.type(searchInput, 'prod');@@ -236,6 +239,7 @@ describe('CheckboxFilterV2 - interactions', () => {await screen.findByTestId('checkbox-value-row-prod');+ await user.click(screen.getByTestId('checkbox-filter-search-toggle'));const searchInput = screen.getByTestId('checkbox-filter-search');await user.type(searchInput, 'xyz-no-match');@@ -343,6 +347,7 @@ describe('CheckboxFilterV2 - interactions', () => {await screen.findByTestId('checkbox-value-row-pod-a-v1');+ await user.click(screen.getByTestId('checkbox-filter-search-toggle'));const searchInput = screen.getByTestId('checkbox-filter-search');await user.type(searchInput, 'pod-a');@@ -515,7 +520,7 @@ describe('CheckboxFilterV2 - interactions', () => {expect(screen.getByTestId('checkbox-filter-clear-all')).toBeInTheDocument();});- it('hides clear button when no filter applied for attribute', async () => {+ it('shows the reset action when expanded even with no active filter', async () => {mockFieldsValuesAPI({stringValues: ['production'],});@@ -530,9 +535,45 @@ describe('CheckboxFilterV2 - interactions', () => {await screen.findByTestId('checkbox-value-row-production');- expect(- screen.queryByTestId('checkbox-filter-clear-all'),- ).not.toBeInTheDocument();+ // Reset is always available on an expanded section now (hover-gated via+ // CSS), not conditional on an active filter.+ expect(screen.getByTestId('checkbox-filter-clear-all')).toBeInTheDocument();+ });++ it('does not dispatch on clear when the key has no filter', async () => {+ const user = userEvent.setup();+ const onFilterChange = jest.fn();++ mockFieldsValuesAPI({+ stringValues: ['production'],+ });++ render(+ <CheckboxFilterV2+ filter={DEFAULT_FILTER}+ source={QuickFiltersSource.TRACES_EXPLORER}+ useFieldApis={DEFAULT_USE_FIELD_APIS}+ onFilterChange={onFilterChange}+ />,+ undefined,+ {+ queryBuilderOverrides: buildQueryBuilderOverrides({+ builder: {+ queryData: [+ {+ filters: { items: [], op: 'AND' },+ filter: { expression: '' },+ },+ ],+ },+ }),+ },+ );++ await screen.findByTestId('checkbox-value-row-production');+ await user.click(screen.getByTestId('checkbox-filter-clear-all'));++ expect(onFilterChange).not.toHaveBeenCalled();});it('calls onFilterChange when clear clicked', async () => {diff --git a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/__tests__/CheckboxFilterV2.states.test.tsx b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/__tests__/CheckboxFilterV2.states.test.tsxindex ffd3a56ba2..133c5e191a 100644--- a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/__tests__/CheckboxFilterV2.states.test.tsx+++ b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/__tests__/CheckboxFilterV2.states.test.tsx@@ -110,6 +110,7 @@ describe('CheckboxFilterV2 - states', () => {await screen.findByTestId('checkbox-value-row-production');+ await user.click(screen.getByTestId('checkbox-filter-search-toggle'));const searchInput = screen.getByTestId('checkbox-filter-search');await user.type(searchInput, 'prod');diff --git a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/__tests__/CheckboxFilterV2Header.test.tsx b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/__tests__/CheckboxFilterV2Header.test.tsxindex 650627879b..7895c18455 100644--- a/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/__tests__/CheckboxFilterV2Header.test.tsx+++ b/frontend/src/components/QuickFilters/FilterRenderers/Checkbox/v2/__tests__/CheckboxFilterV2Header.test.tsx@@ -1,5 +1,6 @@import { render, screen } from '@testing-library/react';import userEvent from '@testing-library/user-event';+import { TooltipProvider } from '@signozhq/ui/tooltip';import { CheckboxFilterV2Header } from '../CheckboxFilterV2Header';@@ -7,9 +8,8 @@ describe('CheckboxFilterV2Header', () => {const defaultProps = {title: 'Environment',isOpen: false,- showClearAll: true,- isSomeFilterPresentForCurrentAttribute: true,onToggleOpen: jest.fn(),+ onToggleSearch: jest.fn(),onClear: jest.fn(),};@@ -31,11 +31,12 @@ describe('CheckboxFilterV2Header', () => {expect(header).toHaveAttribute('data-state', 'closed');});- it('does not show clear button when collapsed', () => {- render(- <CheckboxFilterV2Header {...defaultProps} isOpen={false} showClearAll />,- );+ it('does not render the section actions when collapsed', () => {+ render(<CheckboxFilterV2Header {...defaultProps} isOpen={false} />);+ expect(+ screen.queryByTestId('checkbox-filter-search-toggle'),+ ).not.toBeInTheDocument();expect(screen.queryByTestId('checkbox-filter-clear-all'),).not.toBeInTheDocument();@@ -50,36 +51,13 @@ describe('CheckboxFilterV2Header', () => {expect(header).toHaveAttribute('data-state', 'open');});- it('shows clear button when expanded + showClearAll=true', () => {- render(<CheckboxFilterV2Header {...defaultProps} isOpen showClearAll />);-- expect(screen.getByTestId('checkbox-filter-clear-all')).toBeInTheDocument();- expect(screen.getByText('Clear')).toBeInTheDocument();- });-- it('hides clear button when showClearAll=false', () => {- render(- <CheckboxFilterV2Header {...defaultProps} isOpen showClearAll={false} />,- );-- expect(- screen.queryByTestId('checkbox-filter-clear-all'),- ).not.toBeInTheDocument();- });-- it('hides clear button when no filter present for attribute', () => {- render(- <CheckboxFilterV2Header- {...defaultProps}- isOpen- showClearAll- isSomeFilterPresentForCurrentAttribute={false}- />,- );+ it('renders both search and reset actions when expanded', () => {+ render(<CheckboxFilterV2Header {...defaultProps} isOpen />);expect(- screen.queryByTestId('checkbox-filter-clear-all'),- ).not.toBeInTheDocument();+ screen.getByTestId('checkbox-filter-search-toggle'),+ ).toBeInTheDocument();+ expect(screen.getByTestId('checkbox-filter-clear-all')).toBeInTheDocument();});});@@ -122,28 +100,35 @@ describe('CheckboxFilterV2Header', () => {expect(onToggleOpen).toHaveBeenCalledTimes(1);});- it('calls onClear on clear button click', async () => {+ it('calls onToggleSearch on search click without toggling open', async () => {const user = userEvent.setup();- const onClear = jest.fn();+ const onToggleSearch = jest.fn();+ const onToggleOpen = jest.fn();render(- <CheckboxFilterV2Header {...defaultProps} isOpen onClear={onClear} />,+ <CheckboxFilterV2Header+ {...defaultProps}+ isOpen+ onToggleSearch={onToggleSearch}+ onToggleOpen={onToggleOpen}+ />,);- await user.click(screen.getByTestId('checkbox-filter-clear-all'));+ await user.click(screen.getByTestId('checkbox-filter-search-toggle'));- expect(onClear).toHaveBeenCalledTimes(1);+ expect(onToggleSearch).toHaveBeenCalledTimes(1);+ expect(onToggleOpen).not.toHaveBeenCalled();});- it('clear button click does not trigger onToggleOpen', async () => {+ it('calls onClear on reset click without toggling open', async () => {const user = userEvent.setup();- const onToggleOpen = jest.fn();const onClear = jest.fn();+ const onToggleOpen = jest.fn();render(<CheckboxFilterV2Header{...defaultProps}isOpen- onToggleOpen={onToggleOpen}onClear={onClear}+ onToggleOpen={onToggleOpen}/>,);@@ -153,4 +138,51 @@ describe('CheckboxFilterV2Header', () => {expect(onToggleOpen).not.toHaveBeenCalled();});});++ describe('title tooltip', () => {+ // jsdom has no layout, so truncation is simulated at the prototype level+ // before mount (the component measures in a layout effect).+ function mockTitleWidths(scrollWidth: number, clientWidth: number): void {+ jest+ .spyOn(HTMLElement.prototype, 'scrollWidth', 'get')+ .mockReturnValue(scrollWidth);+ jest+ .spyOn(HTMLElement.prototype, 'clientWidth', 'get')+ .mockReturnValue(clientWidth);+ }++ afterEach(() => {+ jest.restoreAllMocks();+ });++ it('shows the full name on hover when the title is truncated', async () => {+ mockTitleWidths(200, 100);+ const user = userEvent.setup();+ render(+ <TooltipProvider>+ <CheckboxFilterV2Header {...defaultProps} />+ </TooltipProvider>,+ );++ await user.hover(screen.getByText(defaultProps.title));++ await expect(screen.findByRole('tooltip')).resolves.toHaveTextContent(+ defaultProps.title,+ );+ });++ it('shows no tooltip when the title fits', async () => {+ mockTitleWidths(100, 100);+ const user = userEvent.setup();+ render(+ <TooltipProvider>+ <CheckboxFilterV2Header {...defaultProps} />+ </TooltipProvider>,+ );++ await user.hover(screen.getByText(defaultProps.title));++ expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();+ });+ });});diff --git a/frontend/src/components/QuickFilters/FilterRenderers/Duration/Duration.styles.scss b/frontend/src/components/QuickFilters/FilterRenderers/Duration/Duration.styles.scssindex 6f2dc89b06..27d57e7c1a 100644--- a/frontend/src/components/QuickFilters/FilterRenderers/Duration/Duration.styles.scss+++ b/frontend/src/components/QuickFilters/FilterRenderers/Duration/Duration.styles.scss@@ -11,6 +11,21 @@padding-right: 9px !important;}+ .duration-reset {+ opacity: 0;+ transform: translateX(4px);+ pointer-events: none;+ transition:+ opacity 0.16s ease,+ transform 0.16s ease;+ }++ &:hover .duration-reset {+ opacity: 1;+ transform: translateX(0);+ pointer-events: auto;+ }+.ant-collapse-header-text {color: var(--l2-foreground);font-family: Inter;@@ -105,11 +120,6 @@.section-body-header {display: flex;- > button {- position: absolute;- right: 4px;- padding-top: 13px;- }.ant-collapse {width: 100%;}diff --git a/frontend/src/components/QuickFilters/FilterRenderers/Duration/Duration.tsx b/frontend/src/components/QuickFilters/FilterRenderers/Duration/Duration.tsxindex adadac9805..d2357862df 100644--- a/frontend/src/components/QuickFilters/FilterRenderers/Duration/Duration.tsx+++ b/frontend/src/components/QuickFilters/FilterRenderers/Duration/Duration.tsx@@ -1,5 +1,6 @@import { useCallback, useEffect, useMemo, useState } from 'react';-import { Button, Collapse } from 'antd';+import { Collapse } from 'antd';+import { Undo2 } from '@signozhq/icons';import {IQuickFiltersConfig,QuickFiltersSource,@@ -14,12 +15,16 @@ import {AllTraceFilterKeys,AllTraceFilterKeyValue,HandleRunProps,+ traceFilterKeys,unionTagFilterItems,} from 'pages/TracesExplorer/Filter/filterUtils';import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';import { Query, TagFilterItem } from 'types/api/queryBuilder/queryBuilderData';import { v4 as uuid } from 'uuid';+import { clearFilterFromQuery } from '../shared/filterQuery';+import { SectionActionButton } from '../shared/SectionActionButton/SectionActionButton';+import './Duration.styles.scss';export type FilterType = Record<@@ -268,12 +273,19 @@ function Duration({handleRun();}, [selectedFilters]);- const onClearHandler = (e: React.MouseEvent): void => {- e.stopPropagation();- e.preventDefault();-- if (selectedFilters?.durationNanoMin || selectedFilters?.durationNanoMax) {- handleRun({ clearByType: 'durationNano' });+ const onClearHandler = (): void => {+ if (!selectedFilters?.durationNanoMin && !selectedFilters?.durationNanoMax) {+ return;+ }+ const clearedQuery = clearFilterFromQuery({+ currentQuery,+ filterKey: traceFilterKeys.durationNano.key,+ activeQueryIndex,+ });+ if (onFilterChange && isFunction(onFilterChange)) {+ onFilterChange(clearedQuery);+ } else {+ redirectWithQueryBuilderData(clearedQuery);}};@@ -294,18 +306,19 @@ function Duration({/>),label: 'Duration',+ extra: activeKeys.includes('durationNano') ? (+ <div className="duration-reset">+ <SectionActionButton+ icon={<Undo2 size={14} />}+ tooltip="Reset"+ onClick={onClearHandler}+ testId="collapse-duration-clearBtn"+ />+ </div>+ ) : undefined,},]}/>- {activeKeys.includes('durationNano') && (- <Button- type="link"- onClick={onClearHandler}- data-testid="collapse-duration-clearBtn"- >- Clear All- </Button>- )}</div>);}diff --git a/frontend/src/components/QuickFilters/FilterRenderers/shared/SectionActionButton/SectionActionButton.module.scss b/frontend/src/components/QuickFilters/FilterRenderers/shared/SectionActionButton/SectionActionButton.module.scssnew file mode 100644index 0000000000..0d39c8b167--- /dev/null+++ b/frontend/src/components/QuickFilters/FilterRenderers/shared/SectionActionButton/SectionActionButton.module.scss@@ -0,0 +1,8 @@+.iconBtn {+ display: flex;+ align-items: center;+ justify-content: center;+ padding: 2px;+ min-width: 24px;+ height: 24px;+}diff --git a/frontend/src/components/QuickFilters/FilterRenderers/shared/SectionActionButton/SectionActionButton.tsx b/frontend/src/components/QuickFilters/FilterRenderers/shared/SectionActionButton/SectionActionButton.tsxnew file mode 100644index 0000000000..10ad9bce91--- /dev/null+++ b/frontend/src/components/QuickFilters/FilterRenderers/shared/SectionActionButton/SectionActionButton.tsx@@ -0,0 +1,43 @@+import { ReactNode } from 'react';+import { Button } from '@signozhq/ui/button';+import { Tooltip } from 'antd';++import classNames from 'classnames';++import styles from './SectionActionButton.module.scss';++interface SectionActionButtonProps {+ icon: ReactNode;+ tooltip: string;+ onClick: () => void;+ testId: string;+ className?: string;+}++export function SectionActionButton({+ icon,+ tooltip,+ onClick,+ testId,+ className,+}: SectionActionButtonProps): JSX.Element {+ return (+ <Tooltip title={tooltip}>+ <Button+ variant="link"+ color="secondary"+ size="sm"+ className={classNames(styles.iconBtn, className)}+ onMouseDown={(e): void => e.preventDefault()}+ onClick={(e): void => {+ e.stopPropagation();+ e.preventDefault();+ onClick();+ }}+ data-testid={testId}+ >+ {icon}+ </Button>+ </Tooltip>+ );+}diff --git a/frontend/src/components/QuickFilters/FilterRenderers/shared/filterQuery.ts b/frontend/src/components/QuickFilters/FilterRenderers/shared/filterQuery.tsnew file mode 100644index 0000000000..1bcaaa2b7d--- /dev/null+++ b/frontend/src/components/QuickFilters/FilterRenderers/shared/filterQuery.ts@@ -0,0 +1,53 @@+import { removeKeysFromExpression } from 'components/QueryBuilderV2/utils';+import { Query } from 'types/api/queryBuilder/queryBuilderData';++import { getKeySpellings, isKeyMatch } from '../Checkbox/utils';++/**+ * Returns a new query with this filter's clauses for the attribute key removed from+ * the active query, both from the structured filter items and the raw expression.+ * `operators` limits which expression clauses are removed; omit to remove every+ * clause on the key (e.g. duration's >= / <=).+ */+export function clearFilterFromQuery({+ currentQuery,+ filterKey,+ activeQueryIndex,+ operators,+}: {+ currentQuery: Query;+ filterKey: string;+ activeQueryIndex: number;+ operators?: string[];+}): Query {+ return {+ ...currentQuery,+ builder: {+ ...currentQuery.builder,+ queryData: currentQuery.builder.queryData.map((item, idx) => {+ if (idx !== activeQueryIndex) {+ return item;+ }+ return {+ ...item,+ filter: {+ expression: removeKeysFromExpression(+ item.filter?.expression ?? '',+ getKeySpellings(filterKey),+ false,+ operators,+ ),+ },+ filters: {+ ...item.filters,+ items:+ item.filters?.items?.filter(+ (fil) => !isKeyMatch(fil.key?.key, filterKey),+ ) || [],+ op: item.filters?.op || 'AND',+ },+ };+ }),+ },+ };+}