Make WordPress Core

Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#42239 closed defect (bug) (fixed)

Delete Selected button stays active even all selected images in media library are deselected

Reported by: subrataemfluence's profile subrataemfluence Owned by: afercia's profile 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:

  1. Go to Media (grid view)
  2. Click on "Bulk Select" button
  3. Select one or more media files. "Delete Selected" button gets enabled.
  4. To deselect the selected media item(s) click on the tick marks available on upper right corner of each selected media item(s).
  5. Even all item are deselected "Delete Selected" button still stays enabled.

Attachments (3)

cd03e466-660b-4c90-ybad-3f9216d6c4ec.webm (2.6 MB) - added by subrataemfluence 7 years ago.
Screencast
42239.diff (941 bytes) - added by subrataemfluence 7 years ago.
Proposed patch
42239.2.diff (922 bytes) - added by adamsilverstein 7 years ago.

Change History (17)

#1 @subrataemfluence
7 years ago

In case attached webm does not somehow work on some systems, please visit https://youtu.be/flhD6AS_YJQ.

#2 @subrataemfluence
7 years ago

  • Keywords needs-patch added

Working on patch.

#3 follow-up: @adamsilverstein
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.

@subrataemfluence
7 years ago

Proposed patch

#4 in reply to: ↑ 3 @subrataemfluence
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 @adamsilverstein
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 @adamsilverstein
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 @adamsilverstein
7 years ago

In 42239.2.diff

  • 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 @subrataemfluence
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 :)

#9 @joemcgill
7 years ago

  • Milestone changed from Awaiting Review to 4.9.1

#10 @johnbillion
7 years ago

  • Milestone changed from 4.9.1 to 5.0

#11 @pento
6 years ago

  • Milestone changed from 5.0 to 5.1

#12 @afercia
6 years ago

  • Keywords needs-refresh added
  • Owner set to afercia
  • Status changed from new to assigned

The patch seems simple enough and tested. Needs a refresh though, as the built file media-views.js no longer needs to be committed.

#13 @afercia
6 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 44640:

Media: Improve unselecting media in the media bulk selection mode.

Disables the "Delete Selected" button when unselecting media by clicking the
"checkmark" box in the media bulk selection mode.

Props subrataemfluence, adamsilverstein.
Fixes #42239.

#14 @afercia
6 years ago

  • Keywords needs-refresh removed
Note: See TracTickets for help on using tickets.