From 85002b6a7fc415b92efc44a4403f684d25dbc21c Mon Sep 17 00:00:00 2001 From: Lukas Eipert Date: Tue, 22 Jan 2019 16:34:12 +0100 Subject: 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 --- app/assets/javascripts/feature_highlight/feature_highlight.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) { -- cgit v1.2.1