Commit 85002b6a authored by Lukas Eipert's avatar Lukas Eipert Committed by Stan Hu

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
parent 2b834541
...@@ -31,12 +31,14 @@ export function setupFeatureHighlightPopover(id, debounceTimeout = 300) { ...@@ -31,12 +31,14 @@ export function setupFeatureHighlightPopover(id, debounceTimeout = 300) {
.removeAttr('disabled'); .removeAttr('disabled');
} }
const getPriority = e => parseInt(e.dataset.highlightPriority, 10) || 0;
export function findHighestPriorityFeature() { export function findHighestPriorityFeature() {
let priorityFeature; let priorityFeature;
const sortedFeatureEls = [].slice const sortedFeatureEls = [].slice
.call(document.querySelectorAll('.js-feature-highlight')) .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; const [priorityFeatureEl] = sortedFeatureEls;
if (priorityFeatureEl) { if (priorityFeatureEl) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment