Skip to content

Commit

Permalink
Merge pull request gristlabs#352 from incubateur-territoires/filter-s…
Browse files Browse the repository at this point in the history
…earch-insentive-diacritics

Add normalizetext to filter search
  • Loading branch information
berhalak authored Nov 17, 2022
2 parents 044d7a1 + c2d61f1 commit f0e0714
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/client/models/ColumnFilterMenuModel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ColumnFilter } from "app/client/models/ColumnFilter";
import { CellValue } from "app/plugin/GristData";
import { normalizeText } from "app/client/lib/ACIndex";
import { Computed, Disposable, Observable } from "grainjs";
import escapeRegExp = require("lodash/escapeRegExp");
import isNull = require("lodash/isNull");
Expand Down Expand Up @@ -31,11 +32,11 @@ export class ColumnFilterMenuModel extends Disposable {

// computes a set of all keys that matches the search text.
public readonly filterSet = Computed.create(this, this.searchValue, (_use, searchValue) => {
const searchRegex = new RegExp(escapeRegExp(searchValue), 'i');
const searchRegex = new RegExp(escapeRegExp(normalizeText(searchValue)), 'i');
const showAllOptions = ['Bool', 'Choice', 'ChoiceList'].includes(this.columnFilter.columnType);
return new Set(
this._valueCount
.filter(([_, {label, count}]) => (showAllOptions ? true : count) && searchRegex.test(label))
.filter(([_, {label, count}]) => (showAllOptions ? true : count) && searchRegex.test(normalizeText(label)))
.map(([key]) => key)
);
});
Expand Down

0 comments on commit f0e0714

Please sign in to comment.