Skip to content

Check existence of computed value before display#416

Open
gmooren wants to merge 2 commits intoebess:masterfrom
gmooren:master
Open

Check existence of computed value before display#416
gmooren wants to merge 2 commits intoebess:masterfrom
gmooren:master

Conversation

@gmooren
Copy link

@gmooren gmooren commented Oct 4, 2023

There is an issue which became present in Laravel Nova v4 when using single media collections. When a record does not have a media collection as defined in the Files field, it will result in the following frontend error:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'file_name')
    at Proxy.<anonymous> (media-lib-images-field:2:43292)
    at renderComponentRoot (runtime-core.esm-bundler.js:816:1)
    at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js:5701:1)
    at ReactiveEffect.run (reactivity.esm-bundler.js:178:1)
    at instance.update (runtime-core.esm-bundler.js:5814:1)
    at setupRenderEffect (runtime-core.esm-bundler.js:5822:1)
    at mountComponent (runtime-core.esm-bundler.js:5612:1)
    at processComponent (runtime-core.esm-bundler.js:5565:1)
    at patch (runtime-core.esm-bundler.js:5040:1)
    at mountChildren (runtime-core.esm-bundler.js:5284:1)

This is caused by the value attribute in the API response being an empty array. In Nova 4 the error will stop the table drawing process. In Nova 3 the same error is present but the table drawing just continues.

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.

1 participant