diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js b/app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js index bfa15728f2088..b80a4404a2fe4 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js @@ -52,7 +52,7 @@ define([ * @param {Array} data - current component value */ setPrepareToSendData: function (data) { - if (!data.length) { + if (_.isUndefined(data) || !data.length) { data = ''; } diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/element/multiselect.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/element/multiselect.test.js index 30ab33f4a1cf0..165cc1aff3ac5 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/element/multiselect.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/element/multiselect.test.js @@ -52,6 +52,12 @@ define([ expect(obj.source.set).toHaveBeenCalledWith(dataScope + '-prepared-for-send', ''); }); + it('Check method call with undefined as parameter.', function () { + + expect(obj.setPrepareToSendData(undefined)).toBeUndefined(); + expect(obj.source.set).toHaveBeenCalledWith(dataScope + '-prepared-for-send', ''); + }); + it('Check method call with array with data as parameter.', function () { expect(obj.setPrepareToSendData(['1', '2', '3'])).toBeUndefined(); expect(obj.source.set).toHaveBeenCalledWith(dataScope + '-prepared-for-send', ['1', '2', '3']);