Repository navigation
fix(filters): preserve backend metric-based sorting in select filters - #35130
Merged
Merged
Conversation
Fixes broken metric-based sorting (e.g., sort by MAU) in select filter components by preventing frontend alphabetical sorting from overriding backend sort order. Problem: - When sortMetric was specified in filter configuration, the backend would correctly sort data by the specified metric (e.g., MAU, revenue, etc.) - However, the frontend sortComparator was then applying alphabetical sorting on the labels, completely overriding the intended metric-based order - This resulted in filters showing values sorted alphabetically instead of by their actual metric values Solution: - Check if formData.sortMetric is specified before applying sort logic - When sortMetric exists, return 0 to preserve the original backend order - Only apply alphabetical sorting when no sortMetric is configured - Add sortMetric to useCallback dependency array for proper re-rendering This ensures that metric-based sorting (like "sort by MAU") works correctly while maintaining alphabetical sorting as a fallback for other cases. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
I've completed my review and didn't find any issues.
Files scanned
| File Path | Reviewed |
|---|---|
| superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
Contributor
Contributor
|
🎪 Showtime deployed environment on GHA for 0f3953c • Environment: http://44.252.104.2:8080 (admin/admin) |
msyavuz
approved these changes
Sep 13, 2025
2 of 6 tasks
2 of 3 tasks
2 of 3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
Select filters with metric-based sorting were not working correctly:
Expected behavior:
Actual behavior:
sortComparatorwas applying alphabetical sorting on labelsRoot Cause
The
sortComparatorinSelectFilterPlugin.tsxwas always applying alphabetical sorting based onformData.sortAscending, without considering whetherformData.sortMetricwas specified. This meant metric-based backend sorting was being ignored.Solution
1. Check for metric-based sorting:
2. Preserve backend order when sortMetric exists:
sortMetricis specified, return 0 from comparator3. Fallback to alphabetical sorting:
sortMetricis configured4. Update dependencies:
formData.sortMetrictouseCallbackdependency arrayImpact
Files Changed
superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsxTesting
🤖 Generated with Claude Code