Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 14a78bb

Browse files
committed
sort columns on dropdown selectors
1 parent 932e6b2 commit 14a78bb

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/components/modals/newColumn/handlers/AddExistingColumnHandler.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ export class AddExistingColumnHandler extends AbstractHandlerClass<AddColumnModa
2121
// Filter out the columns that are already in the table
2222
const currentColumns = (info.getValueOfAllColumnsAsociatedWith('id') as string[]).map(id => id);
2323
const filteredColumns: Record<string, string> = {};
24-
Object.keys(columnsRaw).filter((columnName: string) => {
25-
return !currentColumns.includes(columnName.toLowerCase())
26-
}).forEach((columnName: string) => {
27-
filteredColumns[columnName] = columnName;
28-
});
24+
Object.keys(columnsRaw)
25+
.sort((a, b) => a.localeCompare(b))
26+
.filter((columnName: string) => {
27+
return !currentColumns.includes(columnName.toLowerCase())
28+
}).forEach((columnName: string) => {
29+
filteredColumns[columnName] = columnName;
30+
});
2931
new Setting(containerEl)
3032
.setName('Select an existing column to add')
3133
.setDesc('Select an existing column to add not included yet in the table')

src/components/portals/DataviewFiltersPortal.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ const DataviewFiltersPortal = (props: DataviewFiltersProps) => {
5050
obtainColumnsFromRows(view, ddbbConfig, emptyFilterConditions, columns)
5151
);
5252
}).then((columns) => {
53-
setPossibleColumns(Object.keys(columns));
53+
setPossibleColumns(
54+
Object.keys(columns).sort((a, b) => a.localeCompare(b))
55+
);
5456
});
5557
}, [ddbbConfig, columns]);
5658

0 commit comments

Comments
 (0)