summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2017-01-26 20:00:13 +0000
committerRobert Speicher <rspeicher@gmail.com>2017-01-27 14:13:46 -0500
commitba6641c754b8b5f2b9c9cbc882f020d867e5ec58 (patch)
tree5f5fc6f4f8d1d78b9d6be1800a175bbc3e96237c
parent33d4e7fd9006058b8f2de369af2fe3e12b47086b (diff)
downloadgitlab-ce-ba6641c754b8b5f2b9c9cbc882f020d867e5ec58.tar.gz
Merge branch '27254-clicking-line-anchor-multiple-times-causes-scroll-position-to-over-correct' into 'master'
Resolve "Clicking line anchor multiple times causes scroll position to over-correct" Closes #27254 See merge request !8791
-rw-r--r--app/assets/javascripts/diff.js.es66
-rw-r--r--app/assets/javascripts/line_highlighter.js5
2 files changed, 7 insertions, 4 deletions
diff --git a/app/assets/javascripts/diff.js.es6 b/app/assets/javascripts/diff.js.es6
index 5e1a4c948aa..35a029194d0 100644
--- a/app/assets/javascripts/diff.js.es6
+++ b/app/assets/javascripts/diff.js.es6
@@ -1,5 +1,7 @@
/* eslint-disable class-methods-use-this */
+//= require lib/utils/url_utility */
+
(() => {
const UNFOLD_COUNT = 20;
@@ -104,11 +106,11 @@
}
highlighSelectedLine() {
+ const hash = gl.utils.getLocationHash();
const $diffFiles = $('.diff-file');
$diffFiles.find('.hll').removeClass('hll');
- if (window.location.hash !== '') {
- const hash = window.location.hash.replace('#', '');
+ if (hash) {
$diffFiles
.find(`tr#${hash}:not(.match) td, td#${hash}, td[data-line-code="${hash}"]`)
.addClass('hll');
diff --git a/app/assets/javascripts/line_highlighter.js b/app/assets/javascripts/line_highlighter.js
index 9af89b79f84..7747e22e115 100644
--- a/app/assets/javascripts/line_highlighter.js
+++ b/app/assets/javascripts/line_highlighter.js
@@ -74,8 +74,9 @@
// If not done this way, the line number anchor will sometimes keep its
// active state even when the event is cancelled, resulting in an ugly border
// around the link and/or a persisted underline text decoration.
- return $('#blob-content-holder').on('click', 'a[data-line-number]', function(event) {
- return event.preventDefault();
+ $('#blob-content-holder').on('click', 'a[data-line-number]', function(event) {
+ event.preventDefault();
+ event.stopPropagation();
});
};