Skip to content

Commit

Permalink
fix: order select filter options
Browse files Browse the repository at this point in the history
  • Loading branch information
schummar committed Jul 19, 2024
1 parent e910dd8 commit 4e7648d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/selectFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ReactNode } from 'react';
import { useEffect, useMemo, useState } from 'react';
import { useFilter } from '../hooks/useFilter';
import { useTheme } from '../hooks/useTheme';
import { asString, castArray, flatMap, uniq } from '../misc/helpers';
import { asString, castArray, flatMap, orderBy, uniq } from '../misc/helpers';
import { useColumnContext, useTableContext } from '../misc/tableContext';
import type { CommonFilterProps, InternalColumn, SerializableValue } from '../types';
import { AutoFocusTextField } from './autoFocusTextField';
Expand Down Expand Up @@ -83,8 +83,10 @@ export function SelectFilter<T, V, F extends SerializableValue>({
| undefined;
if (!column) return [];

return uniq(
flatMap(state.items, (item) => castArray(filterBy(column.value(item.value), item.value))),
return orderBy(
uniq(
flatMap(state.items, (item) => castArray(filterBy(column.value(item.value), item.value))),
),
);
});

Expand Down

0 comments on commit 4e7648d

Please sign in to comment.