-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Closed
Labels
[Block] FileAffects the File BlockAffects the File Block[Feature] BlocksOverall functionality of blocksOverall functionality of blocks[Feature] Drag and DropDrag and drop functionality when working with blocksDrag and drop functionality when working with blocks[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Description
Describe the bug
Refreshing the page after a File Block after an invalid file type has been added results in a block in an erroneous state
Related to umbrella issue #8119, since this happens when the file block edit componentDidMount and triggers particular transitions in state.
To Reproduce
Steps to reproduce the behavior:
- Create a new post
- Drag and drop a file with an unsupported file type (.exe, .dmg, .json etc.)
- Observe that a file block is created and displays an error "Sorry, this file type is not permitted for security reasons."
- Update/Save the post
- Refresh the page
- Observe that 'This block has encountered an error and cannot be previewed.' is displayed where the file block once was.
Expected behavior
The file block should still be displayed and should probably not display any kind of error.
Desktop (please complete the following information):
- OS: Mac OS
- Browser: Chrome
- Version: 67
Additional context
- Discovered while testing File block: Handle drag-and-drop errors #8066, but not caused by it
- This is caused by the file block retaining the 'href' attribute for a blob that no longer exists after previously encountering an error. When mounting after the page reload the
file
variable is undefined. The call tomediaUpload
then results in an error:
gutenberg/core-blocks/file/edit.js
Lines 58 to 68 in 7aacd2d
const file = getBlobByURL( href ); mediaUpload( { allowedType: '*', filesList: [ file ], onFileChange: ( [ media ] ) => this.onSelectFile( media ), onError: ( message ) => { this.setState( { hasError: true } ); noticeOperations.createErrorNotice( message ); }, } );
Metadata
Metadata
Assignees
Labels
[Block] FileAffects the File BlockAffects the File Block[Feature] BlocksOverall functionality of blocksOverall functionality of blocks[Feature] Drag and DropDrag and drop functionality when working with blocksDrag and drop functionality when working with blocks[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended