Updating search in Combobox component

This commit is contained in:
Alexei Koshelev 2022-10-20 14:49:59 +03:00
parent 4d87c6d817
commit 3b2162dc61
2 changed files with 10 additions and 3 deletions

View file

@ -407,8 +407,9 @@ define([
}, },
selectCandidate: function() { selectCandidate: function() {
var index = this._search.index || 0, var index = (this._search.index && this._search.index != -1) ? this._search.index : 0,
re = new RegExp('^' + ((this._search.full) ? this._search.text : this._search.char), 'i'), re = new RegExp('^' + ((this._search.full) ? this._search.text : this._search.char), 'i'),
isFirstCharsEqual = re.test(this.store.at(index).get(this.displayField)),
itemCandidate, idxCandidate; itemCandidate, idxCandidate;
for (var i=0; i<this.store.length; i++) { for (var i=0; i<this.store.length; i++) {
@ -417,6 +418,8 @@ define([
if (!itemCandidate) { if (!itemCandidate) {
itemCandidate = item; itemCandidate = item;
idxCandidate = i; idxCandidate = i;
if(!isFirstCharsEqual)
break;
} }
if (this._search.full && i==index || i>index) { if (this._search.full && i==index || i>index) {
itemCandidate = item; itemCandidate = item;

View file

@ -472,8 +472,9 @@ define([
}, },
selectCandidate: function() { selectCandidate: function() {
var index = this._search.index || 0, var index = (this._search.index && this._search.index != -1) ? this._search.index : 0,
re = new RegExp('^' + ((this._search.full) ? this._search.text : this._search.char), 'i'), re = new RegExp('^' + ((this._search.full) ? this._search.text : this._search.char), 'i'),
isFirstCharsEqual = re.test(this.items[index].caption),
itemCandidate, idxCandidate; itemCandidate, idxCandidate;
for (var i=0; i<this.items.length; i++) { for (var i=0; i<this.items.length; i++) {
@ -482,6 +483,8 @@ define([
if (!itemCandidate) { if (!itemCandidate) {
itemCandidate = item; itemCandidate = item;
idxCandidate = i; idxCandidate = i;
if(!isFirstCharsEqual)
break;
} }
if (this._search.full && i==index || i>index) { if (this._search.full && i==index || i>index) {
itemCandidate = item; itemCandidate = item;
@ -1053,6 +1056,7 @@ define([
selectCandidate: function() { selectCandidate: function() {
var index = (this._search.index && this._search.index != -1) ? this._search.index : 0, var index = (this._search.index && this._search.index != -1) ? this._search.index : 0,
re = new RegExp('^' + ((this._search.full) ? this._search.text : this._search.char), 'i'), re = new RegExp('^' + ((this._search.full) ? this._search.text : this._search.char), 'i'),
isFirstCharsEqual = re.test(this.items[index].caption),
itemCandidate, idxCandidate; itemCandidate, idxCandidate;
for (var i=0; i<this.items.length; i++) { for (var i=0; i<this.items.length; i++) {
@ -1061,7 +1065,7 @@ define([
if (!itemCandidate) { if (!itemCandidate) {
itemCandidate = item; itemCandidate = item;
idxCandidate = i; idxCandidate = i;
if(!re.test(this.items[index].caption)) if(!isFirstCharsEqual)
break; break;
} }
if (this._search.full && i==index || i>index) { if (this._search.full && i==index || i>index) {