From 804d4217fc4023dfd693374ffedeed0284c682de Mon Sep 17 00:00:00 2001 From: mertsincan Date: Fri, 17 Apr 2020 12:26:26 +0300 Subject: [PATCH] Fixed #1335 - Add filterLocale property to ListBox --- src/components/listbox/ListBox.d.ts | 1 + src/components/listbox/ListBox.js | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/listbox/ListBox.d.ts b/src/components/listbox/ListBox.d.ts index 935754dc52..b74bb97348 100755 --- a/src/components/listbox/ListBox.d.ts +++ b/src/components/listbox/ListBox.d.ts @@ -18,6 +18,7 @@ interface ListBoxProps { filterBy?: string; filterMatchMode?: string; filterPlaceholder?: string; + filterLocale?: string; tabIndex?:string; tooltip?: any; tooltipOptions?: TooltipOptions; diff --git a/src/components/listbox/ListBox.js b/src/components/listbox/ListBox.js index 8731a62e9d..4bba9fdb53 100644 --- a/src/components/listbox/ListBox.js +++ b/src/components/listbox/ListBox.js @@ -27,6 +27,7 @@ export class ListBox extends Component { filterBy: null, filterMatchMode: 'contains', filterPlaceholder: null, + filterLocale: undefined, tabIndex: '0', tooltip: null, tooltipOptions: null, @@ -51,6 +52,7 @@ export class ListBox extends Component { filterBy: PropTypes.string, filterMatchMode: PropTypes.string, filterPlaceholder: PropTypes.string, + filterLocale: PropTypes.string, tabIndex: PropTypes.string, tooltip: PropTypes.string, tooltipOptions: PropTypes.object, @@ -242,10 +244,10 @@ export class ListBox extends Component { } filter(option) { - let filterValue = this.state.filter.trim().toLowerCase(); - let optionLabel = this.getOptionLabel(option); + let filterValue = this.state.filter.trim().toLocaleLowerCase(this.props.filterLocale); + let optionLabel = this.getOptionLabel(option).toLocaleLowerCase(this.props.filterLocale); - return optionLabel.toLowerCase().indexOf(filterValue.toLowerCase()) > -1; + return optionLabel.indexOf(filterValue) > -1; } hasFilter() { @@ -269,9 +271,9 @@ export class ListBox extends Component { if (this.props.options) { if (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); } items = items.map((option, index) => {