Skip to content

Commit

Permalink
Merge pull request #35 from Georiviere/Search-result-ignores-capitali…
Browse files Browse the repository at this point in the history
…ze-and-accent

Search result ignores capitalize and accent
  • Loading branch information
babastienne authored Sep 27, 2023
2 parents 1a8d28d + 104df08 commit 555ba58
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 555ba58

Please sign in to comment.