Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Dropdown): remove diacritics on filter #2021

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/modules/Dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,14 @@ export default class Dropdown extends Component {
filteredOptions = search(filteredOptions, searchQuery)
} else {
const re = new RegExp(_.escapeRegExp(searchQuery), 'i')
filteredOptions = _.filter(filteredOptions, opt => re.test(opt.text))
filteredOptions = _.filter(filteredOptions, function (opt) {
Copy link
Member

@levithomason levithomason Aug 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should just be:

-filteredOptions = _.filter(filteredOptions, opt => re.test(opt.text))
+filteredOptions = _.filter(filteredOptions, opt => re.test(_.deburr(opt.text)))

https://lodash.com/docs/4.17.4#deburr

let str = opt.text
if(str) {
// remove diacritics on search
str = str.normalize('NFD').replace(/[\u0300-\u036f]/g, "");
}
return re.test(str);
});
}
}

Expand Down