Skip to content

Commit

Permalink
Search result ignores capitalize and accent
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrucs committed Sep 27, 2023
1 parent 1a8d28d commit 104df08
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/components/map/geojson.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useMemo } from 'react';
import { useSearchParams } from 'next/navigation';
import { Layer } from '@/api/settings';
import slugify from 'slugify';

import { GeometryList } from '@/components/map/geometry-list';

Expand All @@ -21,9 +22,14 @@ export default function GeoJson({ layer }: Props) {
}
return {
...layer.geojson,
features: layer.geojson.features.filter(feature =>
feature.properties?.name?.includes(searchText),
),
features: layer.geojson.features.filter(feature => {
if (!feature.properties?.name) {
return false;
}
return slugify(feature.properties.name, { lower: true }).includes(
slugify(searchText, { lower: true }),
);
}),
};
}, [layer.geojson, layer.isActive, searchParams]);

Expand Down

0 comments on commit 104df08

Please sign in to comment.