FIX: Made reorder more convenient by clamping the entered number

FIX: Made reorder more convenient by clamping the entered number

diff --git a/app/assets/javascripts/discourse/controllers/reorder-categories.js.es6 b/app/assets/javascripts/discourse/controllers/reorder-categories.js.es6
index 16d9352..1e9200b 100644
--- a/app/assets/javascripts/discourse/controllers/reorder-categories.js.es6
+++ b/app/assets/javascripts/discourse/controllers/reorder-categories.js.es6
@@ -85,7 +85,8 @@ export default Ember.Controller.extend(ModalFunctionality, Ember.Evented, {
   actions: {
     change(cat, e) {
       let position = parseInt($(e.target).val());
-      this.moveDir(cat, position - this.get("categoriesOrdered").indexOf(cat));
+      let amount = Math.min(Math.max(position, 0), this.get("categoriesOrdered").length - 1);
+      this.moveDir(cat, amount - this.get("categoriesOrdered").indexOf(cat));
     },
 
     moveUp(cat) {

GitHub sha: 4af0a2f0

1 Like