Skip to content

Comments

Analytics filter refinements#49

Open
tomerqodo wants to merge 10 commits intocoderabbit_full_base_analytics_filter_refinements_pr11from
coderabbit_full_head_analytics_filter_refinements_pr11
Open

Analytics filter refinements#49
tomerqodo wants to merge 10 commits intocoderabbit_full_base_analytics_filter_refinements_pr11from
coderabbit_full_head_analytics_filter_refinements_pr11

Conversation

@tomerqodo
Copy link

@tomerqodo tomerqodo commented Jan 28, 2026

Benchmark PR from agentic-review-benchmarks#11

Summary by CodeRabbit

Release Notes

  • New Features

    • Dropdowns now support optional auto-closing after selection for improved workflow efficiency.
  • Bug Fixes

    • Improved dropdown and filter state management for consistent behavior.
    • Enhanced popover transition stability during open/close interactions.
  • Style

    • Visual refinements to filter controls and button styling.
    • Updated spacing, sizing, and layout adjustments across filter components.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 28, 2026

Walkthrough

The changes introduce a new optional autoCloseOnSelect property to filter configuration alongside behavioral enhancements for dropdown and popover management. Updates include auto-close logic on selection, search input reset on popover close, improved close handling paths, minor styling adjustments, and filter visibility controls in the stats module. Default i18n values are also updated.

Changes

Cohort / File(s) Summary
Filter Component Core
apps/shade/src/components/ui/filters.tsx
Added autoCloseOnSelect?: boolean property to FilterFieldConfig<T> interface. Implemented auto-close behavior in SelectOptionsPopover and Add Filter flow conditional on this property. Added search input reset on popover close and improved close handling to clear selection state. Applied animation suppression flags to popover/overlay wrappers for predictable transitions. Updated small filter input padding from 1.5 to 2 px. Updated default i18n values for addFilter and addFilterTitle to empty strings.
Stats Filter Configuration
apps/stats/src/views/Stats/components/stats-filter.tsx
Updated UTM and source option renderers to use lighter text-based styling instead of icon badges. Added selectedOptionsClassName: 'hidden' to UTM option groups and Source field to hide selected items while maintaining searchability. Changed Post field icon from File to PenLine with fixed width constraints (w-80) and enabled asyncSearch. Added defaultOperator, hideOperatorSelect, and autoCloseOnSelect properties to Audience field. Updated Filters component invocation with FunnelPlus icon, adjusted button sizing (sm variant), and reordered button classes.
Stats Header Layout
apps/stats/src/views/Stats/layout/stats-header.tsx
Replaced py-8 with pb-6 pt-9 in Navbar className to adjust top and bottom padding spacing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A filter now knows when to close with grace,
Dropdowns hide selections, keeping the place,
New properties bloom in configuration,
Popovers reset for better sensation,
Search clears itself—pristine and neat!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Analytics filter refinements' is directly related to the main changes in the PR, which involve multiple refinements to filter components across the analytics stats module including auto-close behavior, UI adjustments, and layout improvements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
apps/shade/src/components/ui/filters.tsx (1)

105-122: Avoid empty default Add Filter labels (accessibility regression).
Setting DEFAULT_I18N.addFilter/addFilterTitle to '' makes the default add button icon-only with no accessible name for consumers that don’t override i18n. Consider keeping non-empty defaults or add a fallback label elsewhere.

🔧 Suggested fix
-    addFilter: '',
+    addFilter: 'Add filter',
...
-    addFilterTitle: '',
+    addFilterTitle: 'Add filter'
apps/stats/src/views/Stats/components/stats-filter.tsx (1)

448-456: Use canonical operator key for audience default operator.
FilterOperator values in the filters UI are snake_case (e.g., is_any_of). Using 'is any of' won’t match and can break operator lookups downstream.

🐛 Suggested fix
-                        defaultOperator: 'is any of',
+                        defaultOperator: 'is_any_of',
🤖 Fix all issues with AI agents
In `@apps/shade/src/components/ui/filters.tsx`:
- Around line 2098-2101: The onClose handler for the add-filter popover
currently calls setAddFilterOpen(false) and setSelectedFieldKeyForOptions(null)
but does not clear tempSelectedValues, which allows stale selections to persist
and leak into subsequent fields (affecting autoCloseOnSelect and
single/multi-select behavior); update the onClose callback to also reset
tempSelectedValues (e.g., call setTempSelectedValues([]) or the appropriate
empty value) so that when onClose is invoked the temporary selection state is
cleared along with setAddFilterOpen and setSelectedFieldKeyForOptions.

In `@apps/stats/src/views/Stats/components/stats-filter.tsx`:
- Around line 497-504: The icon-only add button currently has no accessible name
because addButtonText is empty; update the JSX where addButtonIcon/addButtonText
are set to supply an accessible label — either set addButtonText='Add filter'
(or a localized equivalent) or pass an explicit aria-label via a prop like
addButtonProps={{ 'aria-label': 'Add filter' }} on the same component so the add
button has a programmatic name; modify the snippet that sets addButtonIcon and
addButtonText in stats-filter.tsx accordingly.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b27cd6f and cf39011.

📒 Files selected for processing (3)
  • apps/shade/src/components/ui/filters.tsx
  • apps/stats/src/views/Stats/components/stats-filter.tsx
  • apps/stats/src/views/Stats/layout/stats-header.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
apps/shade/src/components/ui/filters.tsx (2)
apps/shade/src/components/ui/popover.tsx (1)
  • PopoverContent (31-31)
apps/shade/src/index.ts (1)
  • cn (82-82)
🔇 Additional comments (10)
apps/stats/src/views/Stats/layout/stats-header.tsx (1)

67-67: Navbar padding tweak looks good.

apps/shade/src/components/ui/filters.tsx (6)

239-239: LGTM on the small input padding tweak.


750-751: autoCloseOnSelect flag addition looks good.


946-948: Operator label styling adjustment looks fine.


1049-1052: Resetting search input on close is a nice cleanup.


1125-1137: Auto-close behavior on selection is consistent.

Also applies to: 1271-1274


1201-1207: Closed-state animation suppression looks consistent across popovers.

Also applies to: 1644-1644, 2078-2084

apps/stats/src/views/Stats/components/stats-filter.tsx (3)

93-96: Badge text-style swap looks good.

Also applies to: 159-162


386-440: UTM/source dropdown visibility tweaks look fine.

Also applies to: 483-485


458-471: Post selector sizing/icon updates look good.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment on lines +2098 to +2101
onClose={() => {
setAddFilterOpen(false);
setSelectedFieldKeyForOptions(null);
}}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Clear tempSelectedValues when closing via onClose.
When autoCloseOnSelect closes the add-filter popover, tempSelectedValues isn’t cleared, so the next field can inherit stale values and even flip a single-select into multiselect behavior.

🐛 Suggested fix
 onClose={() => {
     setAddFilterOpen(false);
     setSelectedFieldKeyForOptions(null);
+    setTempSelectedValues([]);
 }}
🤖 Prompt for AI Agents
In `@apps/shade/src/components/ui/filters.tsx` around lines 2098 - 2101, The
onClose handler for the add-filter popover currently calls
setAddFilterOpen(false) and setSelectedFieldKeyForOptions(null) but does not
clear tempSelectedValues, which allows stale selections to persist and leak into
subsequent fields (affecting autoCloseOnSelect and single/multi-select
behavior); update the onClose callback to also reset tempSelectedValues (e.g.,
call setTempSelectedValues([]) or the appropriate empty value) so that when
onClose is invoked the temporary selection state is cleared along with
setAddFilterOpen and setSelectedFieldKeyForOptions.

Comment on lines +497 to 504
addButtonIcon={<LucideIcon.FunnelPlus />}
addButtonText={filters.length ? '' : ''}
className='mb-6 [&>button]:order-last'
fields={groupedFields}
filters={filters}
showSearchInput={false}
size='sm'
onChange={handleFilterChange}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Provide an accessible label for the icon-only add button.
With addButtonText empty and defaults now blank, the button can end up without an accessible name. Please supply a label (or custom button with aria-label) to keep it accessible.

🔧 Example fix
-            addButtonText={filters.length ? '' : ''}
+            addButtonText="Add filter"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
addButtonIcon={<LucideIcon.FunnelPlus />}
addButtonText={filters.length ? '' : ''}
className='mb-6 [&>button]:order-last'
fields={groupedFields}
filters={filters}
showSearchInput={false}
size='sm'
onChange={handleFilterChange}
addButtonIcon={<LucideIcon.FunnelPlus />}
addButtonText="Add filter"
className='mb-6 [&>button]:order-last'
fields={groupedFields}
filters={filters}
showSearchInput={false}
size='sm'
onChange={handleFilterChange}
🤖 Prompt for AI Agents
In `@apps/stats/src/views/Stats/components/stats-filter.tsx` around lines 497 -
504, The icon-only add button currently has no accessible name because
addButtonText is empty; update the JSX where addButtonIcon/addButtonText are set
to supply an accessible label — either set addButtonText='Add filter' (or a
localized equivalent) or pass an explicit aria-label via a prop like
addButtonProps={{ 'aria-label': 'Add filter' }} on the same component so the add
button has a programmatic name; modify the snippet that sets addButtonIcon and
addButtonText in stats-filter.tsx accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants