From 68e835433a9fa63e21c414db800270308181d2c3 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Thu, 25 Feb 2021 20:09:12 -0500 Subject: [PATCH] ui: sort unsafe options first so they're less likely to be hidden --- .../ui/src/components/ui-components/AdvancedMultiSelect.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js b/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js index 670b99cd7..8503a74fc 100644 --- a/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js +++ b/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js @@ -48,13 +48,14 @@ class AdvancedMultiSelect extends React.Component { }; } - // Sort options alphabetically. "Unsafe" options float to the bottom" + // Sort options alphabetically. "Unsafe" options float to the top so that they + // do not get selected and hidden at the bottom of the list. compareOptions = (a, b) => { // Apparently, you can use additive operators with boolean types. Ultimately, // the ToNumber() abstraction operation is called to convert the booleans to // numbers: https://tc39.es/ecma262/#sec-tonumeric - if (this.isSafe(b.value) - this.isSafe(a.value) !== 0) { - return this.isSafe(b.value) - this.isSafe(a.value); + if (this.isSafe(a.value) - this.isSafe(b.value) !== 0) { + return this.isSafe(a.value) - this.isSafe(b.value); } return a.value.localeCompare(b.value);