summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Eipert <leipert@gitlab.com>2019-01-22 16:34:12 +0100
committerStan Hu <stanhu@gmail.com>2019-01-22 11:23:37 -0800
commit85002b6a7fc415b92efc44a4403f684d25dbc21c (patch)
treea7ceb0e87a873e9abb0d0d5555a818025f681588
parent2b8345414175c667c257bf45a35ede61956d1dd7 (diff)
downloadgitlab-ce-85002b6a7fc415b92efc44a4403f684d25dbc21c.tar.gz
Fix sorting in feature_highlight
Apparently the Array.sort function was used in a wrong way. Instead of returning a number indicating order [0] it returned a boolean. This fixes that. [0]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
-rw-r--r--app/assets/javascripts/feature_highlight/feature_highlight.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/assets/javascripts/feature_highlight/feature_highlight.js b/app/assets/javascripts/feature_highlight/feature_highlight.js
index 173fe7c69de..be55e6923c6 100644
--- a/app/assets/javascripts/feature_highlight/feature_highlight.js
+++ b/app/assets/javascripts/feature_highlight/feature_highlight.js
@@ -31,12 +31,14 @@ export function setupFeatureHighlightPopover(id, debounceTimeout = 300) {
.removeAttr('disabled');
}
+const getPriority = e => parseInt(e.dataset.highlightPriority, 10) || 0;
+
export function findHighestPriorityFeature() {
let priorityFeature;
const sortedFeatureEls = [].slice
.call(document.querySelectorAll('.js-feature-highlight'))
- .sort((a, b) => (a.dataset.highlightPriority || 0) < (b.dataset.highlightPriority || 0));
+ .sort((a, b) => getPriority(b) - getPriority(a));
const [priorityFeatureEl] = sortedFeatureEls;
if (priorityFeatureEl) {