Skip to content

Commit

Permalink
Components: Refactor Autocomplete away from _.deburr() (#42266)
Browse files Browse the repository at this point in the history
* Components: Refactor Autocomplete away from _.deburr()

* Add changelog
  • Loading branch information
tyxla authored Jul 11, 2022
1 parent c80eb71 commit b79f747
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- `Slot`/`Fill`: Refactor away from Lodash ([#42153](https://github.com/WordPress/gutenberg/pull/42153/)).
- `ComboboxControl`: Refactor away from `_.deburr()` ([#42169](https://github.com/WordPress/gutenberg/pull/42169/)).
- `FormTokenField`: Refactor away from `_.identity()` ([#42215](https://github.com/WordPress/gutenberg/pull/42215/)).
- `Autocomplete`: Refactor away from `_.deburr()` ([#42266](https://github.com/WordPress/gutenberg/pull/42266/)).
- `MenuItem`: Refactor away from `_.isString()` ([#42268](https://github.com/WordPress/gutenberg/pull/42268/)).
- `Shortcut`: Refactor away from `_.isString()` ([#42268](https://github.com/WordPress/gutenberg/pull/42268/)).

Expand Down
5 changes: 3 additions & 2 deletions packages/components/src/autocomplete/get-default-use-items.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* External dependencies
*/
import { debounce, deburr, escapeRegExp } from 'lodash';
import { debounce, escapeRegExp } from 'lodash';
import removeAccents from 'remove-accents';

/**
* WordPress dependencies
Expand All @@ -20,7 +21,7 @@ function filterOptions( search, options = [], maxResults = 10 ) {
}

const isMatch = keywords.some( ( keyword ) =>
search.test( deburr( keyword ) )
search.test( removeAccents( keyword ) )
);
if ( ! isMatch ) {
continue;
Expand Down
5 changes: 3 additions & 2 deletions packages/components/src/autocomplete/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* External dependencies
*/
import { escapeRegExp, find, deburr } from 'lodash';
import { escapeRegExp, find } from 'lodash';
import removeAccents from 'remove-accents';

/**
* WordPress dependencies
Expand Down Expand Up @@ -284,7 +285,7 @@ function useAutocomplete( {
return;
}

const text = deburr( textContent );
const text = removeAccents( textContent );
const textAfterSelection = getTextContent(
slice( record, undefined, getTextContent( record ).length )
);
Expand Down

0 comments on commit b79f747

Please sign in to comment.