From b428df51e5c319a392c431fe6b5fde5ebba562f2 Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Tue, 21 Jun 2016 13:34:19 +0000 Subject: [PATCH] Media: Restore keyboard navigation of the media grid. This changes the binding of event listeners in the Attachments Browser to use `on` instead of `listenTo` for the `attachment:keydown:arrow` and `attachment:details:shift-tab` events. The existing listeners broke when we upgraded Backbone in [36546]. Props adamsilverstein. Fixes #36900. git-svn-id: https://develop.svn.wordpress.org/trunk@37755 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/media-views.js | 4 ++-- src/wp-includes/js/media/views/attachments/browser.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js index 596e4b0ba3..e8a8202d59 100644 --- a/src/wp-includes/js/media-views.js +++ b/src/wp-includes/js/media-views.js @@ -4085,8 +4085,8 @@ AttachmentsBrowser = View.extend({ }); // Add keydown listener to the instance of the Attachments view - this.attachments.listenTo( this.controller, 'attachment:keydown:arrow', this.attachments.arrowEvent ); - this.attachments.listenTo( this.controller, 'attachment:details:shift-tab', this.attachments.restoreFocus ); + this.controller.on( 'attachment:keydown:arrow', _.bind( this.attachments.arrowEvent, this.attachments ) ); + this.controller.on( 'attachment:details:shift-tab', _.bind( this.attachments.restoreFocus, this.attachments ) ); this.views.add( this.attachments ); diff --git a/src/wp-includes/js/media/views/attachments/browser.js b/src/wp-includes/js/media/views/attachments/browser.js index 819d251b3c..bd83278afc 100644 --- a/src/wp-includes/js/media/views/attachments/browser.js +++ b/src/wp-includes/js/media/views/attachments/browser.js @@ -354,8 +354,8 @@ AttachmentsBrowser = View.extend({ }); // Add keydown listener to the instance of the Attachments view - this.attachments.listenTo( this.controller, 'attachment:keydown:arrow', this.attachments.arrowEvent ); - this.attachments.listenTo( this.controller, 'attachment:details:shift-tab', this.attachments.restoreFocus ); + this.controller.on( 'attachment:keydown:arrow', _.bind( this.attachments.arrowEvent, this.attachments ) ); + this.controller.on( 'attachment:details:shift-tab', _.bind( this.attachments.restoreFocus, this.attachments ) ); this.views.add( this.attachments );