I have run into an issue in the smart-query-builder
when upgrading from version 15 to 16. We configure a query field with a lookup.dataSource
that is a function. Though I don’t see documentation that says it can be a function (docs just say it should be an array), this has been supported, and there is still logic that handles this*. However, there has been new logic added to _keyupHandler()
that breaks when dataSource
is a function:
if (t.dataSource && t.dataSource.length) { // if t.dataSource is a function, length is the number of parameters
for (let e = 0; e < t.dataSource.length; e++) {
const o = t.dataSource[e]; // can't index a function, so o is undefined
if ("string" == typeof o) {
...
} else if (void 0 !== o.label && o.label === t.$.input.value) { // error here trying to access label on undefined!
...
}
}
}
*E.g. the open()
function contains: "function" == typeof e.dataSource ? e.dataSource(e.query, t) : t(e.dataSource)
As I describe in the source comments, when dataSource
is a function, the length
property is the number of parameters, but then the code tries to index into it like an array. The resulting error prevents the control from working correctly.