You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The reason will be displayed to describe this comment to others. Learn more.
@rakeshkumar1019
Kind of quick win fix but only delay a little the display of results and in the end didn't fix at all the root cause of the initial issue reported in SUPNXP-34884 :
Results from "Ele" come after 5 secondes so it override the one for the complete word "Elexir" that take 2 seconds to complete. Here a 500ms debounce value won't change anything. It's about the logic not the params.
A good fix would be to define 2 new integer properties on the element :
lastQueryId
lastCompletedQueryId
Then update the _searchTermChanged function with something like this
`_searchTermChanged: function() {
this.$.selector.selected = 0;
const currentQuery = this.searchTerm;
const currentQueryId = ++this.lastQueryId; // increment and get a unique ID for this query
if (this.searchTerm === '') {
this.items = [];
} else {
this.debounce('suggester-search', function() {
this.$.op.execute().then(function() {
// Check if this query is later than the last completed query
if (currentQueryId >= this.lastCompletedQueryId) {
this.lastCompletedQueryId = currentQueryId; // Update the last completed query ID
// ... your existing logic to populate this.items
}
}.bind(this));
}.bind(this), this.searchDelay);
}
};`
this insure that you display results in the order of the queries made, but skip any results that return out-of-order, i.e., if a newer query has already returned results
6dff339
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rakeshkumar1019
Kind of quick win fix but only delay a little the display of results and in the end didn't fix at all the root cause of the initial issue reported in SUPNXP-34884 :
Results from "Ele" come after 5 secondes so it override the one for the complete word "Elexir" that take 2 seconds to complete. Here a 500ms debounce value won't change anything. It's about the logic not the params.
A good fix would be to define 2 new integer properties on the element :
Then update the _searchTermChanged function with something like this
`_searchTermChanged: function() {
this.$.selector.selected = 0;
const currentQuery = this.searchTerm;
const currentQueryId = ++this.lastQueryId; // increment and get a unique ID for this query
if (this.searchTerm === '') {
this.items = [];
} else {
this.debounce('suggester-search', function() {
this.$.op.execute().then(function() {
// Check if this query is later than the last completed query
if (currentQueryId >= this.lastCompletedQueryId) {
this.lastCompletedQueryId = currentQueryId; // Update the last completed query ID
// ... your existing logic to populate this.items
}
}.bind(this));
}.bind(this), this.searchDelay);
}
};`
this insure that you display results in the order of the queries made, but skip any results that return out-of-order, i.e., if a newer query has already returned results