diff options
author | Lukas Eipert <leipert@gitlab.com> | 2019-01-22 18:34:12 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-01-22 22:23:37 +0300 |
commit | 85002b6a7fc415b92efc44a4403f684d25dbc21c (patch) | |
tree | a7ceb0e87a873e9abb0d0d5555a818025f681588 /app/assets/javascripts/feature_highlight | |
parent | 2b8345414175c667c257bf45a35ede61956d1dd7 (diff) |
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
Diffstat (limited to 'app/assets/javascripts/feature_highlight')
-rw-r--r-- | app/assets/javascripts/feature_highlight/feature_highlight.js | 4 |
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) { |