#42239 closed defect (bug) (fixed)
Delete Selected button stays active even all selected images in media library are deselected
Reported by: | subrataemfluence | Owned by: | afercia |
---|---|---|---|
Milestone: | 5.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Media | Keywords: | has-patch |
Focuses: | javascript, administration | Cc: |
Description
There is an issue with "Delete Selected" button in media library. The button stays active even when all media items are deselected.
Steps to reproduce:
- Go to Media (grid view)
- Click on "Bulk Select" button
- Select one or more media files. "Delete Selected" button gets enabled.
- To deselect the selected media item(s) click on the tick marks available on upper right corner of each selected media item(s).
- Even all item are deselected "Delete Selected" button still stays enabled.
Attachments (3)
Change History (17)
#1
@
7 years ago
In case attached webm does not somehow work on some systems, please visit https://youtu.be/flhD6AS_YJQ.
#3
follow-up:
↓ 4
@
7 years ago
@subrataemfluence
Thanks for the bug report and for working on a patch!
I think this worked correctly in the past so it may be worth testing back on previous versions and seeing when exactly this broke (maybe you can find the exact commit with git bisect
). In addition, the version dropdown on the ticket should ideally be set to the version that first included the bug.
#4
in reply to:
↑ 3
@
7 years ago
- Keywords has-patch added; needs-patch removed
- Version 4.8.2 deleted
Thanks a lot for telling me. Please let me know how do I know which earlier version had this bug
report. Trying to become a better contributor!
For now I have removed the version info.
I have however, attached a proposed patch. Please let me know if this works.
[7:42]
I am still a learner and do not know all such little but important things.
Replying to adamsilverstein:
@subrataemfluence
Thanks for the bug report and for working on a patch!
I think this worked correctly in the past so it may be worth testing back on previous versions and seeing when exactly this broke (maybe you can find the exact commit with
git bisect
). In addition, the version dropdown on the ticket should ideally be set to the version that first included the bug.
#5
@
7 years ago
@subrataemfluence Thanks for the patch, I will review...
Please let me know how do I know which earlier version had this bug
Easiest is probably to install copies of each version locally and try to reproduce, eg does the bug happen in 4.7? in 4.6? sometimes the bug goes back to when a feature was introduced. You don't have to do this, however sometimes its helpful when hunting for a solution.
#6
@
7 years ago
Nice work! I tested your patch and verified it resolves the issue, however it feels like a brute force approach and I want to dig a bit further to see if I can determine why/when this broke. Also, before your patch, how is the button enabled when you select your first item? Shouldn't that code logic also handle disabling the button?
#7
@
7 years ago
- Trigger the controller
selection:toggle
event when clicking the 'check' box in the media bulk selection mode.
The DeleteSelected
button (wp-includes/js/media/views/button/delete-selected.js) listens for this event on the controller and calls toggleDisabled
which properly enables or disables the model, triggering a button rerender in the correct state. Before this patch this worked only when clicking on the images themselves to toggle, this extends that to the check box in the upper right corner of each image.
@subrataemfluence can you give this patch a test and verify it resolves the issue you were seeing?
#8
@
7 years ago
@adamsilverstein I have tested the patch and now everything is working nicely.
I understand that my approach was not the right one. Thank you for showing me the right way of doing this :)
Screencast