Opened 20 months ago
Last modified 20 months ago
#57637 new defect (bug)
ImageEdit component can be exited with unsaved state
Reported by: | benlk | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 6.1.1 |
Component: | Media | Keywords: | has-patch |
Focuses: | ui, administration | Cc: |
Description
The image-edit component https://github.com/WordPress/WordPress/blob/master/wp-admin/js/image-edit.js used to crop and perform other edit interactions on images has a notsaved
method, which is sometimes called to prevent closing the dialog if the user has made edits to the image without saving the image.
This is not consistently checked, which means that users can exit the dialog without being asked if they want to save unsaved changes.
Steps to reproduce on a post with Gutenberg:
- Create a new post, or edit an existing post.
- Add a new image block, or click on an existing one.
- Click on the "Replace" button on the block control bar.
- Click on "Open Media Library"
- Click on "Edit Image"
- Make a crop to the image by click-and-dragging on the image, then click "Crop".
- The modal is now in an unsaved state.
- Clicking "Cancel" below the image triggers the
notsaved()
check, where if the user clicks "Cancel", the closure fails. - Clicking here does not trigger the check, and closes the dialog: the greyed-out modal background, the modal's "X", the modal's "Back" button in the bottom right, the browser close-tab button
The above workflow reproduces in the Media Library, if you click "Edit Image" in the per-image view.
The simple fix would be to remove the if ( warn )
conditional here, and only check if notsaved()
before closing: https://github.com/WordPress/WordPress/blob/0ed99784d829eec393a9b2fa3b2c71824295c95c/wp-admin/js/image-edit.js#L848-L853
This affects WP 6.1.1 and, 6.1.0, 6.0, and probably previous versions.
Change History (2)
#1
@
20 months ago
This ticket was mentioned in PR #4002 on WordPress/wordpress-develop by @benlk.
20 months ago
#2
- Keywords has-patch added
For https://core.trac.wordpress.org/ticket/57637
Trac ticket:
Proposed patch: https://github.com/WordPress/WordPress/pull/632