summaryrefslogtreecommitdiff
path: root/app/assets
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2017-01-26 20:00:13 +0000
committerFatih Acet <acetfatih@gmail.com>2017-01-26 20:00:13 +0000
commitabc50fa5146e8ed01306bb96addc7efe48196207 (patch)
treecd17bf29f1fb4a1fd0a3ab2dde1b3c0c67356ed7 /app/assets
parent9eb39ddeb48d884d7c24ef2796139daf10a9d911 (diff)
parent5fbce6832826bdea9be8d305b0dc28a533d010ae (diff)
downloadgitlab-ce-abc50fa5146e8ed01306bb96addc7efe48196207.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
Diffstat (limited to 'app/assets')
-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 4620715a521..2f147704c22 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();
});
};