Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(admin-ui): Fix error if no array of assets is provided #1249

Merged
merged 1 commit into from
Nov 30, 2021
Merged

Fix(admin-ui): Fix error if no array of assets is provided #1249

merged 1 commit into from
Nov 30, 2021

Conversation

Spielboerg
Copy link
Contributor

If no assets array is set via the assets input of the ProductAssetsComponent this error is thrown:

ERROR TypeError: Cannot read properties of undefined (reading 'slice')
    at ProductAssetsComponent.set assetsSetter [as assetsSetter] (vendure-admin-ui-catalog.js:7092)
    at setInputsForProperty (core.js:10960)
    at elementPropertyInternal (core.js:10004)
    at Module.ɵɵproperty (core.js:14787)
    at RecipeDetailComponent_Template (recipe-detail.component.html:61)
    at executeTemplate (core.js:9599)
    at refreshView (core.js:9465)
    at refreshComponent (core.js:10636)
    at refreshChildComponents (core.js:9261)
    at refreshView (core.js:9515)

This pull request fixes this by using an empty array as a fallback.

I can change it to this alternative and more robust implementation if you like this solution better:

this.assets = Array.isArray(val) ? val.slice() : [];

@michaelbromley michaelbromley merged commit 5af2b12 into vendure-ecommerce:master Nov 30, 2021
@michaelbromley
Copy link
Member

Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants