Opened 8 years ago
Closed 8 years ago
#36900 closed defect (bug) (fixed)
Media grid AttachmentsBrowser arrows navigation and restoreFocus() no longer work
Reported by: | afercia | Owned by: | adamsilverstein |
---|---|---|---|
Milestone: | 4.5.3 | Priority: | normal |
Severity: | normal | Version: | 4.5 |
Component: | Media | Keywords: | fixed-major |
Focuses: | javascript | Cc: |
Description
In WordPress 4.4, the media grid allows to navigate attachments in all directions using the Up/Down/Left/Right arrow keys. Also, when in the details sidebar and tabbing backwards, focus is restored to the currently selected attachment.
In WordPress 4.5 these two functionalities no longer work. Sorry can't help more than this, just tracked down to:
in AttachmentsBrowser.createAttachments()
which runs on AttachmentsBrowser.initialize()
these two callbacks no longer work:
this.attachments.listenTo( this.controller, 'attachment:keydown:arrow', this.attachments.arrowEvent ); this.attachments.listenTo( this.controller, 'attachment:details:shift-tab', this.attachments.restoreFocus );
probably related to the changes in Backbone.js 1.2.0, see [36546]
/cc @wonderboymusic @adamsilverstein
Attachments (2)
Change History (16)
#2
@
8 years ago
- Owner set to adamsilverstein
- Status changed from new to assigned
@afercia Thanks for the bug report and tracking down the source!
We have seen this type of issue elsewhere in core since upgrading Backbone and tried to track down every case, unfortunately we missed a few. Backbone limited the way events are registered over the two years Core hadn't upgraded (mentioned on the commit you referenced), however this instance doesn't match those patterns.
I will dig in to see how we can fix this. (on a related note, Backbone is now at version 1.3.3 and includes some bug fixes from our bundled version. I will open a ticket to upgrade again for 4.6)
#3
@
8 years ago
@adamsilverstein thanks :) some more info: I've tried with Backbone 1.3.3 (just overwriting files on my local install) and that didn't help. Tried also to revert Backbone to the version used in 4.4 and everything worked again.
#5
@
8 years ago
- Keywords has-patch needs-testing added
- Milestone changed from Awaiting Review to 4.5.3
listenTo
isn't really required here and seems to be the point of failure, switching to the .on
form (and binding the attachments for context) fixes the issue.
In 36900.diff
- Switch from
listenTo
toon
when binding listeners to handle keyboard navigation and image re-focus in the media grid; the existing listeners broke when we upgraded Backbone in [36546].
Marking for consideration for 4.5.3 since this is a 4.5 regression. @afercia can you please test my patch to verify this fixes the issue you raised?
#6
@
8 years ago
Works for me. :)
Tested on latest Chrome, Firefox and IE 11. Tested also on IE 8... the whole media modal is so slow that actually it seems freezed... but it works. That's a separate issue but worth considering starting a discussion about browsers support.
This ticket was mentioned in Slack in #core-images by mike. View the logs.
8 years ago
This ticket was mentioned in Slack in #core-images by joemcgill. View the logs.
8 years ago
#10
@
8 years ago
36900.2.diff Applies the same changes from 36900.diff to the source file, src/wp-includes/js/media/views/attachments/browser.js
and I've included the modified file after running grunt precommit
so it's easier to apply and test without running a build step.
#11
@
8 years ago
Looks good @joemcgill - sorry I am always a little confused how I should provide patches for these compiled media files. I'll try to patch both source and generated in the future to make your job as a committer easier.
Worth considering there are probably other places where this doesn't work any longer.