Skip to content

Commit

Permalink
Fixed #1338 - Add filterLocale property to Tree
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Apr 17, 2020
1 parent 0cab565 commit b5b3dd9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/tree/Tree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface TreeProps {
filterBy?: any;
filterMode?: string;
filterPlaceholder?: string;
filterLocale?: string;
nodeTemplate?(node: any): JSX.Element;
onSelect?(e: {originalEvent: Event, node: TreeNode}): void;
onUnselect?(e: {originalEvent: Event, node: TreeNode}): void;
Expand Down
6 changes: 4 additions & 2 deletions src/components/tree/Tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class Tree extends Component {
filterBy: 'label',
filterMode: 'lenient',
filterPlaceholder: null,
filterLocale: undefined,
nodeTemplate: null,
onSelect: null,
onUnselect: null,
Expand Down Expand Up @@ -64,6 +65,7 @@ export class Tree extends Component {
filterBy: PropTypes.any,
filterMode: PropTypes.string,
filterPlaceholder: PropTypes.string,
filterLocale: PropTypes.string,
nodeTemplate: PropTypes.func,
onSelect: PropTypes.func,
onUnselect: PropTypes.func,
Expand Down Expand Up @@ -294,7 +296,7 @@ export class Tree extends Component {
else {
this.filteredNodes = [];
const searchFields = this.props.filterBy.split(',');
const filterText = this.state.filter.toLowerCase();
const filterText = this.state.filter.toLocaleLowerCase(this.props.filterLocale);
const isStrictMode = this.props.filterMode === 'strict';
for(let node of this.props.value) {
let copyNode = {...node};
Expand Down Expand Up @@ -333,7 +335,7 @@ export class Tree extends Component {
isFilterMatched(node, {searchFields, filterText, isStrictMode}) {
let matched = false;
for(let field of searchFields) {
let fieldValue = String(ObjectUtils.resolveFieldData(node, field)).toLowerCase();
let fieldValue = String(ObjectUtils.resolveFieldData(node, field)).toLocaleLowerCase(this.props.filterLocale);
if(fieldValue.indexOf(filterText) > -1) {
matched = true;
}
Expand Down

0 comments on commit b5b3dd9

Please sign in to comment.