Skip to content

Commit

Permalink
Fixed #1334 - Add filterLocale property to Dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Apr 17, 2020
1 parent dbe7322 commit 4907320
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/components/dropdown/Dropdown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface DropdownProps {
filterBy?: string;
filterMatchMode?: string;
filterPlaceholder?: string;
filterLocale?: string;
editable?:boolean;
placeholder?: string;
required?: boolean;
Expand Down
10 changes: 6 additions & 4 deletions src/components/dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class Dropdown extends Component {
filterBy: null,
filterMatchMode: 'contains',
filterPlaceholder: null,
filterLocale: undefined,
editable: false,
placeholder:null,
required: false,
Expand Down Expand Up @@ -65,6 +66,7 @@ export class Dropdown extends Component {
filterBy: PropTypes.string,
filterMatchMode: PropTypes.string,
filterPlaceholder: PropTypes.string,
filterLocale: PropTypes.string,
editable:PropTypes.bool,
placeholder: PropTypes.string,
required: PropTypes.bool,
Expand Down Expand Up @@ -272,8 +274,8 @@ export class Dropdown extends Component {
searchOptionInRange(start, end) {
for (let i = start; i < end; i++) {
let opt = this.props.options[i];
let label = this.getOptionLabel(opt).toString().toLowerCase();
if (label.startsWith(this.searchValue.toLowerCase())) {
let label = this.getOptionLabel(opt).toString().toLocaleLowerCase(this.props.filterLocale)
if (label.startsWith(this.searchValue.toLocaleLowerCase(this.props.filterLocale))) {
return opt;
}
}
Expand Down Expand Up @@ -593,9 +595,9 @@ export class Dropdown extends Component {
let items = this.props.options;

if (items && this.hasFilter()) {
let filterValue = this.state.filter.trim().toLowerCase();
let filterValue = this.state.filter.trim().toLocaleLowerCase(this.props.filterLocale);
let searchFields = this.props.filterBy ? this.props.filterBy.split(',') : [this.props.optionLabel || 'label'];
items = FilterUtils.filter(items, searchFields, filterValue, this.props.filterMatchMode);
items = FilterUtils.filter(items, searchFields, filterValue, this.props.filterMatchMode, this.props.filterLocale);
}

if(items) {
Expand Down

0 comments on commit 4907320

Please sign in to comment.