From 4af0a2f00bbd108e7ebb5db3b9b55bd7a929d04a Mon Sep 17 00:00:00 2001 From: venarius Date: Sun, 17 Mar 2019 16:32:02 +0100 Subject: [PATCH] FIX: Made reorder more convenient by clamping the entered number --- .../discourse/controllers/reorder-categories.js.es6 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/controllers/reorder-categories.js.es6 b/app/assets/javascripts/discourse/controllers/reorder-categories.js.es6 index 16d93523c67..1e9200b741e 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) {