craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.29k stars 638 forks source link

[4.x & 5.x]: Error when using Live Preview after uploading an asset #14832

Closed tommysvr closed 7 months ago

tommysvr commented 7 months ago

What happened?

Description

Getting an Uncaught (in promise) DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string error when uploading an asset and then trying to preview an entry.

Steps to reproduce

  1. Click 'Upload Files' on an assets field
  2. Upload an image
  3. Click 'Preview'

Tested on a local filesystem, asset field settings are all set to the default. Dragging an image onto the field works without error.

Tested in Chrome, Safari and Firefox - the error differs slightly in each.

https://github.com/craftcms/cms/assets/867566/3a46f9b2-8de2-4924-9060-7015de3fa974

Expected behavior

Live Preview loads correctly

Actual behavior

Live Preview window doesn't show, and this error is shown in the browser console:

jquery.js?v=1707205984:2 Uncaught (in promise) DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string.
    at HTMLInputElement.<anonymous> (https://craft5.ddev.site/cpresources/624f2193/jquery.js?v=1707205984:2:67445)
    at Function.each (https://craft5.ddev.site/cpresources/624f2193/jquery.js?v=1707205984:2:3091)
    at T.fn.init.each (https://craft5.ddev.site/cpresources/624f2193/jquery.js?v=1707205984:2:1571)
    at T.fn.init.val (https://craft5.ddev.site/cpresources/624f2193/jquery.js?v=1707205984:2:67137)
    at Object.copyInputValues (https://craft5.ddev.site/cpresources/1ab53bc8/garnish.js?v=1711503619:2:112805)
    at s.constructor._getClone (https://craft5.ddev.site/cpresources/ef40e11e/cp.js?v=1713140127:2:632336)
    at s.constructor.open (https://craft5.ddev.site/cpresources/ef40e11e/cp.js?v=1713140127:2:622757)
    at s.constructor.<anonymous> (https://craft5.ddev.site/cpresources/ef40e11e/cp.js?v=1713140127:2:451105)
    at f (https://craft5.ddev.site/cpresources/ef40e11e/cp.js?v=1713140127:2:425357)
    at Generator.<anonymous> (https://craft5.ddev.site/cpresources/ef40e11e/cp.js?v=1713140127:2:426703)

Craft CMS version

Tested on 4.8.9 & 5.0.4

PHP version

8.2

Operating system and version

No response

Database type and version

MySQL 8.0

Image driver and version

No response

Installed plugins and versions

-

brandonkelly commented 7 months ago

Thanks for reporting that Tommy! Fixed for the next release.

brandonkelly commented 7 months ago

Craft 4.8.10 and 5.0.5 are out with that fix.