fix single filter value

This commit is contained in:
Maxime-J 2023-11-05 17:11:50 +00:00
parent d5eddeae24
commit f016970186

View File

@ -21,12 +21,16 @@ export default function FieldFilterForm({
const formattedValues = useMemo(() => {
const formatted = {};
const { compare } = new Intl.Collator(locale, { numeric: true });
const format = val => {
formatted[val] = formatValue(val, name);
return formatted[val];
};
values.sort((a, b) => compare(formatted[a] ?? format(a), formatted[b] ?? format(b)));
if (values.length !== 1) {
const { compare } = new Intl.Collator(locale, { numeric: true });
values.sort((a, b) => compare(formatted[a] ?? format(a), formatted[b] ?? format(b)));
} else {
format(values[0]);
}
return formatted;
}, [values]);