From 8790d81cb45576b1ff6ba6fb47cf8b863dee8b27 Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Wed, 30 Jul 2014 17:38:18 +0000 Subject: [PATCH] Prevent key event handlers from firing when in input areas in the media modal, as people understandably want to type inside said inputs. props kovshenin. fixes #28704. git-svn-id: https://develop.svn.wordpress.org/trunk@29331 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/media-views.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js index c6b3301a1b..480293e89e 100644 --- a/src/wp-includes/js/media-views.js +++ b/src/wp-includes/js/media-views.js @@ -4752,6 +4752,11 @@ toggleSelectionHandler: function( event ) { var method; + // Don't do anything inside inputs. + if ( 'input' === event.target.tagName.toLowerCase() ) { + return + } + // Catch arrow events if ( 37 === event.keyCode || 38 === event.keyCode || 39 === event.keyCode || 40 === event.keyCode ) { this.arrowEvent(event); @@ -4767,6 +4772,9 @@ if ( this.controller.isModeActive( 'grid' ) ) { // Pass the current target to restore focus when closing this.controller.trigger( 'edit:attachment', this.model, event.currentTarget ); + + // Don't scroll the view and don't attempt to submit anything. + event.stopPropagation(); return; } @@ -4779,6 +4787,9 @@ this.toggleSelection({ method: method }); + + // Don't scroll the view and don't attempt to submit anything. + event.stopPropagation(); }, /** * @param {Object} event