diff options
author | Phil Hughes <me@iamphill.com> | 2017-06-20 10:45:28 +0300 |
---|---|---|
committer | kushalpandya <kushal@gitlab.com> | 2017-06-20 11:34:50 +0300 |
commit | 9a415064c03ed6e18719209e51eed92d712e120c (patch) | |
tree | e14100efe92d4c0ff33465aed0f03ef3e232ce1f | |
parent | 4cf4b1650e52ac82ad8087bdf1bdf7393b644442 (diff) |
Merge branch '33916-make-note-highlight-toggle-boolean-explcit' into 'master'
Fix note highlight being added when you don't have a URL fragment hash #note_xxx
Closes #33916
See merge request !12293
-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 d56cf959486..88e834815e1 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 c6f218e4dac..0ae0b2fd103 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); }); }); |