I am trying to figure out a JS error I am receiving in a Magento e-commerce extension that I paid good money for, but support has been lacking on their end to fix this. Error causes a spinning wheel of doom on page load that never goes away.
The following is the error I receive in the developer console:
Uncaught TypeError: data.some is not a function
at findFirst (select.js:67)
at UiClass.normalizeData (select.js:193)
at UiClass.normalizeData (wrapper.js:109)
at UiClass.getInitialValue (abstract.js:200)
at UiClass.setInitialValue (abstract.js:143)
at UiClass._super (wrapper.js:106)
at UiClass.setInitialValue (select.js:302)
at UiClass.setInitialValue (wrapper.js:109)
at UiClass.initialize (abstract.js:70)
at UiClass.initialize (wrapper.js:109)
This is the code section at line 67 of select.js data.some(function (node) { the error is referencing:
/**
* Recursively loops over data to find non-undefined, non-array value
*
* @param {Array} data
* @return {*} - first non-undefined value in array
*/
function findFirst(data) {
var value;
data.some(function (node) {
value = node.value;
if (Array.isArray(value)) {
value = findFirst(value);
}
return !_.isUndefined(value);
});
return value;
}
I am hoping this is just some kind of typo error that I might be able to fix on my own?
Thanks in advance for any help.
P.S. I am a coding novice.
3
Answers
In Magento 2.1.8 there was a method removed that may affect certain extensions – it affected ours called getOptionArray().
To fix it in our extension in: Ui/DataProvider/Product/Form/Modifier/FixedSelectionType.php
becomes:
and in the model/attribute folder add this method, in our case the full path is: Model/Attribute/Sources/FixedType.php
and above the public function getalloptions() method add this:
I got this issue in Magento 2.2.3 version too. The issue was found with the file,
vendor/magento/module-ui/view/base/web/js/form/element/select.js
.We need to override and add the changes to the file as below. Find the code,
Replace with the updated code,
This solved the issue for me. Thanks!
I’ve got this issue while creating a form using UI Components, specifically Select component. I was missing the
caption
element, so if anybody encounter this issue they might be missing an element.