Commit 19e12aac authored by Eric Eastwood's avatar Eric Eastwood

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
parent 025cbc2a
...@@ -322,7 +322,9 @@ const normalizeNewlines = function(str) { ...@@ -322,7 +322,9 @@ const normalizeNewlines = function(str) {
Notes.updateNoteTargetSelector = function($note) { Notes.updateNoteTargetSelector = function($note) {
const hash = gl.utils.getLocationHash(); 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);
}; };
/* /*
......
...@@ -176,7 +176,7 @@ import '~/notes'; ...@@ -176,7 +176,7 @@ import '~/notes';
Notes.updateNoteTargetSelector($note); Notes.updateNoteTargetSelector($note);
expect($note.toggleClass).toHaveBeenCalledWith('target', null); expect($note.toggleClass).toHaveBeenCalledWith('target', false);
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment