optimal-select
optimal-select copied to clipboard
Priority order is not being honored
Looks like the findAttributesPattern function is not properly sorting the attributes by the priority array properly. Looks like the sort comparison check is not correct. changing the sort code to this below seemed to resolve the issue
var outsidePriority = priority.length + 1; // greater than any priority position var sortedKeys = Object.keys(attributes).sort(function (curr, next) { var currPos = priority.indexOf(attributes[curr].name); var nextPos = priority.indexOf(attributes[next].name);
if (nextPos == -1) nextPos = outsidePriority;
if (currPos == -1) currPos = outsidePriority;
if (nextPos > currPos) { return -1;}
if (nextPos < currPos) { return 1;}
return 0;
/* old code if (nextPos === -1) { if (currPos === -1) { return 0; } return -1; } return currPos - nextPos; */ });