diff options
author | Eric Eastwood <contact@ericeastwood.com> | 2017-06-20 02:43:08 +0300 |
---|---|---|
committer | Eric Eastwood <contact@ericeastwood.com> | 2017-06-20 02:52:19 +0300 |
commit | 19e12aac0217efae6b474d8601928a217064fb21 (patch) | |
tree | 8982e2c5cac148330a5bb5eb24e30b7f954eb847 | |
parent | 025cbc2ad4dc175634676ff8a6955e043512d8bf (diff) |
Fix note highlight being added to new notes
Always use a explicit true/false value to set highlight because jQuery
assumes `null` means toggle from whatever state and doesn't force false.
Regressed in
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12098
-rw-r--r-- | app/assets/javascripts/notes.js | 4 | ||||
-rw-r--r-- | spec/javascripts/notes_spec.js | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index f12a35f0485..6a6dabfd00c 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -322,7 +322,9 @@ const normalizeNewlines = function(str) { Notes.updateNoteTargetSelector = function($note) { const hash = gl.utils.getLocationHash(); - $note.toggleClass('target', hash && $note.filter(`#${hash}`).length > 0); + // Needs to be an explicit true/false for the jQuery `toggleClass(force)` + const addTargetClass = Boolean(hash && $note.filter(`#${hash}`).length > 0); + $note.toggleClass('target', addTargetClass); }; /* diff --git a/spec/javascripts/notes_spec.js b/spec/javascripts/notes_spec.js index b272f43a166..5ece4ed080b 100644 --- a/spec/javascripts/notes_spec.js +++ b/spec/javascripts/notes_spec.js @@ -176,7 +176,7 @@ import '~/notes'; Notes.updateNoteTargetSelector($note); - expect($note.toggleClass).toHaveBeenCalledWith('target', null); + expect($note.toggleClass).toHaveBeenCalledWith('target', false); }); }); |