summaryrefslogtreecommitdiff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorPaul Slaughter <pslaughter@gitlab.com>2019-08-15 10:11:36 -0500
committerPaul Slaughter <pslaughter@gitlab.com>2019-08-15 10:11:36 -0500
commite55c7a9a3572ad37a8b69cd2d3db9ab24b5ba5ab (patch)
tree28e81b60678f7ed0b4290c479e8e7bc504313b0b /app/assets/javascripts
parent0495615502198e208fb9cb50d29adf26525b9b17 (diff)
downloadgitlab-ce-e55c7a9a3572ad37a8b69cd2d3db9ab24b5ba5ab.tar.gz
Add key unbinds to DiscussionKeyboardNavigatorfe-add-unbinds-to-discussion-keyboard-navigator
Also adds comment to explain why this works on the diff-tab when it's only used in `notes-app`. https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/30144#note_204066538
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/mr_notes/init_notes.js4
-rw-r--r--app/assets/javascripts/notes/components/discussion_keyboard_navigator.vue4
2 files changed, 8 insertions, 0 deletions
diff --git a/app/assets/javascripts/mr_notes/init_notes.js b/app/assets/javascripts/mr_notes/init_notes.js
index 8caac68e0d4..622db360d1f 100644
--- a/app/assets/javascripts/mr_notes/init_notes.js
+++ b/app/assets/javascripts/mr_notes/init_notes.js
@@ -59,6 +59,10 @@ export default () => {
render(createElement) {
const isDiffView = this.activeTab === 'diffs';
+ // NOTE: Even though `discussionKeyboardNavigator` is added to the `notes-app`,
+ // it adds a global key listener so it works on the diffs tab as well.
+ // If we create a single Vue app for all of the MR tabs, we should move this
+ // up the tree, to the root.
return createElement(discussionKeyboardNavigator, { props: { isDiffView } }, [
createElement('notes-app', {
props: {
diff --git a/app/assets/javascripts/notes/components/discussion_keyboard_navigator.vue b/app/assets/javascripts/notes/components/discussion_keyboard_navigator.vue
index 5fc2b6ba04c..7fbfe8eebb2 100644
--- a/app/assets/javascripts/notes/components/discussion_keyboard_navigator.vue
+++ b/app/assets/javascripts/notes/components/discussion_keyboard_navigator.vue
@@ -25,6 +25,10 @@ export default {
Mousetrap.bind('n', () => this.jumpToNextDiscussion());
Mousetrap.bind('p', () => this.jumpToPreviousDiscussion());
},
+ beforeDestroy() {
+ Mousetrap.unbind('n');
+ Mousetrap.unbind('p');
+ },
methods: {
...mapActions(['expandDiscussion']),
jumpToNextDiscussion() {