You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2025/09/13 01:59:58 UTC
(superset) branch fix/filter-value-metric-based-sorting created (now 0f3953c739)
This is an automated email from the ASF dual-hosted git repository.
elizabeth pushed a change to branch fix/filter-value-metric-based-sorting
in repository https://gitbox.apache.org/repos/asf/superset.git
at 0f3953c739 fix(filters): preserve backend metric-based sorting in select filters
This branch includes the following new commits:
new 0f3953c739 fix(filters): preserve backend metric-based sorting in select filters
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(superset) 01/01: fix(filters): preserve backend metric-based sorting in select filters
Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
elizabeth pushed a commit to branch fix/filter-value-metric-based-sorting
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 0f3953c73934019d26cd43fa99373350170e3cd6
Author: Elizabeth Thompson <es...@gmail.com>
AuthorDate: Fri Sep 12 18:59:29 2025 -0700
fix(filters): preserve backend metric-based sorting in select filters
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 <no...@anthropic.com>
---
.../src/filters/components/Select/SelectFilterPlugin.tsx | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx b/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx
index b792360786..a76bf8af1e 100644
--- a/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx
+++ b/superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx
@@ -317,13 +317,20 @@ export default function PluginFilterSelect(props: PluginFilterSelectProps) {
const sortComparator = useCallback(
(a: LabeledValue, b: LabeledValue) => {
+ // When sortMetric is specified, the backend already sorted the data correctly
+ // Don't override the backend's metric-based sorting with frontend alphabetical sorting
+ if (formData.sortMetric) {
+ return 0; // Preserve the original order from the backend
+ }
+
+ // Only apply alphabetical sorting when no sortMetric is specified
const labelComparator = propertyComparator('label');
if (formData.sortAscending) {
return labelComparator(a, b);
}
return labelComparator(b, a);
},
- [formData.sortAscending],
+ [formData.sortAscending, formData.sortMetric],
);
// Use effect for initialisation for filter plugin