Skip to content

Commit

Permalink
[0.11.8] Support using options with numeric value attribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
ledsoft committed Oct 10, 2024
1 parent 7cce611 commit fd25c56
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 13 deletions.
16 changes: 16 additions & 0 deletions examples/data/data-with-numeric-value.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"id": 1234,
"label": "Option 1",
"children": [1236]
},
{
"id": 1235,
"label": "Option 2"
},
{
"id": 1236,
"label": "Option 3",
"parent": 1234
}
]
10 changes: 5 additions & 5 deletions lib/components/IntelligentTreeSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ class IntelligentTreeSelect extends _react.Component {
);
}
}
_isInHistory(searchString) {
searchString = searchString.toLowerCase();
_isInHistory(searchValue) {
searchValue = searchValue.toString().toLowerCase();
for (let i = 0; i < this.history.length; i++) {
if (this.history[i].searchString.toLowerCase() === searchString) {
if (this.history[i].searchString.toLowerCase() === searchValue) {
if (Date.now() < this.history[i].validTo) {
return true;
}
Expand Down Expand Up @@ -401,7 +401,7 @@ class IntelligentTreeSelect extends _react.Component {
return this.props.valueRenderer(children, data);
}
const {valueKey, labelKey, getOptionLabel} = this.props;
const value = data[valueKey];
const value = data[valueKey].toString();
if ((0, _Utils.isURL)(value)) {
return /*#__PURE__*/ _react.default.createElement(
"a",
Expand Down Expand Up @@ -517,7 +517,7 @@ class IntelligentTreeSelect extends _react.Component {
}
_addToHistory(searchString, validTo) {
this.history.unshift({
searchString,
searchString: searchString.toString(),
validTo,
});
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Jakub Lečbych"
},
"description": "React tree select component based on [react-select](https://github.com/JedWatson/react-select#react-select) with [react-window](https://github.com/bvaughn/react-window)-based rendering of options.",
"version": "0.11.7",
"version": "0.11.8",
"bugs": {
"url": "https://github.com/lecbyjak/intelligent-tree-select/issues"
},
Expand Down
10 changes: 5 additions & 5 deletions src/components/IntelligentTreeSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ class IntelligentTreeSelect extends Component {
}
}

_isInHistory(searchString) {
searchString = searchString.toLowerCase();
_isInHistory(searchValue) {
searchValue = searchValue.toString().toLowerCase();

for (let i = 0; i < this.history.length; i++) {
if (this.history[i].searchString.toLowerCase() === searchString) {
if (this.history[i].searchString.toLowerCase() === searchValue) {
if (Date.now() < this.history[i].validTo) {
return true;
}
Expand Down Expand Up @@ -376,7 +376,7 @@ class IntelligentTreeSelect extends Component {
return this.props.valueRenderer(children, data);
}
const {valueKey, labelKey, getOptionLabel} = this.props;
const value = data[valueKey];
const value = data[valueKey].toString();

if (isURL(value)) {
return (
Expand Down Expand Up @@ -497,7 +497,7 @@ class IntelligentTreeSelect extends Component {
}

_addToHistory(searchString, validTo) {
this.history.unshift({searchString, validTo});
this.history.unshift({searchString: searchString.toString(), validTo});
}

render() {
Expand Down

0 comments on commit fd25c56

Please sign in to comment.