You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by be...@apache.org on 2025/07/31 15:28:52 UTC
(superset) 01/01: fix: time grain and DB dropdowns
This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch fix-db-dropdown
in repository https://gitbox.apache.org/repos/asf/superset.git
commit b2b5635aebfc15f7ecaae25499acf77f0e4ef251
Author: Beto Dealmeida <ro...@dealmeida.net>
AuthorDate: Thu Jul 31 11:28:39 2025 -0400
fix: time grain and DB dropdowns
---
.../src/shared-controls/sharedControls.tsx | 2 ++
.../src/features/databases/DatabaseModal/index.tsx | 21 +++++++++++++++------
.../components/TimeGrain/TimeGrainFilterPlugin.tsx | 1 +
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/sharedControls.tsx b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/sharedControls.tsx
index f456d98e22..ae359a70f7 100644
--- a/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/sharedControls.tsx
+++ b/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/sharedControls.tsx
@@ -177,6 +177,7 @@ const granularity: SharedControlConfig<'SelectControl'> = {
'can type and use simple natural language as in `10 seconds`, ' +
'`1 day` or `56 weeks`',
),
+ sortComparator: () => 0, // Disable frontend sorting to preserve backend order
};
const time_grain_sqla: SharedControlConfig<'SelectControl'> = {
@@ -204,6 +205,7 @@ const time_grain_sqla: SharedControlConfig<'SelectControl'> = {
choices: (datasource as Dataset)?.time_grain_sqla || [],
}),
visibility: displayTimeRelatedControls,
+ sortComparator: () => 0, // Disable frontend sorting to preserve backend order
};
const time_range: SharedControlConfig<'DateFilterControl'> = {
diff --git a/superset-frontend/src/features/databases/DatabaseModal/index.tsx b/superset-frontend/src/features/databases/DatabaseModal/index.tsx
index 79fac7b8e9..a0dae61762 100644
--- a/superset-frontend/src/features/databases/DatabaseModal/index.tsx
+++ b/superset-frontend/src/features/databases/DatabaseModal/index.tsx
@@ -1087,18 +1087,27 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
onChange={setDatabaseModel}
placeholder={t('Choose a database...')}
options={[
- ...(availableDbs?.databases || [])
- .sort((a: DatabaseForm, b: DatabaseForm) =>
- a.name.localeCompare(b.name),
- )
- .map((database: DatabaseForm, index: number) => ({
+ ...(availableDbs?.databases || []).map(
+ (database: DatabaseForm, index: number) => ({
value: database.name,
label: database.name,
key: `database-${index}`,
- })),
+ }),
+ ),
{ value: 'Other', label: t('Other'), key: 'Other' },
]}
showSearch
+ sortComparator={(a, b) => {
+ // Always put "Other" at the end
+ if (a.value === 'Other') return 1;
+ if (b.value === 'Other') return -1;
+ // For all other options, sort alphabetically
+ return String(a.label).localeCompare(String(b.label));
+ }}
+ getPopupContainer={triggerNode =>
+ triggerNode.parentElement || document.body
+ }
+ dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
/>
<Alert
showIcon
diff --git a/superset-frontend/src/filters/components/TimeGrain/TimeGrainFilterPlugin.tsx b/superset-frontend/src/filters/components/TimeGrain/TimeGrainFilterPlugin.tsx
index e3be55a882..aeff9fbc5a 100644
--- a/superset-frontend/src/filters/components/TimeGrain/TimeGrainFilterPlugin.tsx
+++ b/superset-frontend/src/filters/components/TimeGrain/TimeGrainFilterPlugin.tsx
@@ -134,6 +134,7 @@ export default function PluginFilterTimegrain(
ref={inputRef}
options={options}
onOpenChange={setFilterActive}
+ sortComparator={() => 0} // Disable frontend sorting to preserve backend order
/>
</FormItem>
</FilterPluginStyle>