From 9ced7966742cf2987fd396023147cf3bd97003c9 Mon Sep 17 00:00:00 2001 From: Arun Israel Date: Sat, 5 Apr 2014 01:38:00 -0400 Subject: [PATCH] [bugfix] Fix for '/' keyboard shortcut putting '/' into search input Changed the search button binding from a click binding in mousetrap.js to a function binding. Added a showSearch function that uses jquery to click the '#search-button' element and the function returns false preventing the default action and stops the keydown event from bubbling upwards. Meta Discourse Bug Thread: https://meta.discourse.org/t/shortcut-for-search-leaves-a-in-the-search-field/14394 Mousetrap reference: http://craig.is/killing/mice --- .../discourse/components/keyboard_shortcuts_component.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js b/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js index 6db20f7e6..21fe55c0f 100644 --- a/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js +++ b/app/assets/javascripts/discourse/components/keyboard_shortcuts_component.js @@ -36,7 +36,6 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ 'R': 'article.selected button.create', // reply to selected post 's': '#topic-footer-buttons button.share', // share topic 'S': 'article.selected button.share', // share selected post - '/': '#search-button', // focus search '!': 'article.selected button.flag' // flag selected post }, @@ -48,6 +47,7 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ 'u': 'goBack', '`': 'nextSection', '~': 'prevSection', + '/': 'showSearch', '?': 'showHelpModal' // open keyboard shortcut help }, @@ -92,6 +92,11 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ this._changeSection(-1); }, + showSearch: function() { + $('#search-button').click(); + return false; + }, + showHelpModal: function() { Discourse.__container__.lookup('controller:application').send('showKeyboardShortcutsHelp'); },