Skip to content

Commit

Permalink
Add lodash deburr to autocomplete so that is works with diacritics (#…
Browse files Browse the repository at this point in the history
…10770)

* Add lodash deburr to autocomplete so that is works when the input string starts with an Umlaut

* Update autocompleter so that both the search terms and the keywords are run through lodash's deburr function to allow using characters with diacrytics
  • Loading branch information
brentswisher authored and youknowriad committed Oct 27, 2018
1 parent dfbda26 commit e5b9987
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/components/src/autocomplete/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import classnames from 'classnames';
import { escapeRegExp, find, map, debounce } from 'lodash';
import { escapeRegExp, find, map, debounce, deburr } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -122,7 +122,7 @@ function filterOptions( search, options = [], maxResults = 10 ) {
keywords = [ ...keywords, option.label ];
}

const isMatch = keywords.some( ( keyword ) => search.test( keyword ) );
const isMatch = keywords.some( ( keyword ) => search.test( deburr( keyword ) ) );
if ( ! isMatch ) {
continue;
}
Expand Down Expand Up @@ -382,8 +382,8 @@ export class Autocomplete extends Component {
}

if ( isCollapsed( record ) ) {
const text = getTextContent( slice( record, 0 ) );
const prevText = getTextContent( slice( prevRecord, 0 ) );
const text = deburr( getTextContent( slice( record, 0 ) ) );
const prevText = deburr( getTextContent( slice( prevRecord, 0 ) ) );

if ( text !== prevText ) {
const textAfterSelection = getTextContent( slice( record, undefined, getTextContent( record ).length ) );
Expand Down

0 comments on commit e5b9987

Please sign in to comment.