FIX: when selecting "votes" it would not be selected

FIX: when selecting “votes” it would not be selected

This corrects an issue where selecting votes would not be highlighted in the nav bar

Requires latest Discourse

diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 0000000..86ed71b
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,93 @@
+{
+  "env": {
+    "jasmine": true,
+    "node": true,
+    "mocha": true,
+    "browser": true,
+    "builtin": true
+  },
+  "parserOptions": {
+    "ecmaVersion": 7,
+    "sourceType": "module"
+  },
+  "globals": {
+    "Ember": true,
+    "jQuery": true,
+    "$": true,
+    "QUnit": true,
+    "RSVP": true,
+    "Discourse": true,
+    "Handlebars": true,
+    "I18n": true,
+    "bootbox": true,
+    "moduleFor": true,
+    "moduleForComponent": true,
+    "Pretender": true,
+    "sandbox": true,
+    "controllerFor": true,
+    "test": true,
+    "visit": true,
+    "andThen": true,
+    "click": true,
+    "currentPath": true,
+    "currentRouteName": true,
+    "currentURL": true,
+    "fillIn": true,
+    "keyEvent": true,
+    "triggerEvent": true,
+    "count": true,
+    "exists": true,
+    "visible": true,
+    "invisible": true,
+    "asyncRender": true,
+    "asyncTestDiscourse": true,
+    "fixture": true,
+    "find": true,
+    "sinon": true,
+    "moment": true,
+    "_": true,
+    "alert": true,
+    "define": true,
+    "require": true,
+    "requirejs": true,
+    "hasModule": true,
+    "Blob": true,
+    "File": true
+  },
+  "rules": {
+    "block-scoped-var": 2,
+    "dot-notation": 0,
+    "eqeqeq": [2, "allow-null"],
+    "guard-for-in": 2,
+    "no-bitwise": 2,
+    "no-caller": 2,
+    "no-cond-assign": 0,
+    "no-debugger": 2,
+    "no-empty": 0,
+    "no-eval": 2,
+    "no-extend-native": 2,
+    "no-extra-parens": 0,
+    "no-inner-declarations": 2,
+    "no-irregular-whitespace": 2,
+    "no-iterator": 2,
+    "no-loop-func": 2,
+    "no-multi-str": 2,
+    "no-new": 2,
+    "no-plusplus": 0,
+    "no-proto": 2,
+    "no-script-url": 2,
+    "no-sequences": 2,
+    "no-shadow": 2,
+    "no-undef": 2,
+    "no-unused-vars": 2,
+    "no-with": 2,
+    "no-this-before-super": 2,
+    "semi": 2,
+    "strict": 0,
+    "valid-typeof": 2,
+    "wrap-iife": [2, "inside"],
+    "no-mixed-spaces-and-tabs": 2,
+    "no-trailing-spaces": 2
+  },
+  "parser": "babel-eslint"
+}
diff --git a/assets/javascripts/discourse/initializers/discourse-voting.js.es6 b/assets/javascripts/discourse/initializers/discourse-voting.js.es6
index 5accead..a2af038 100644
--- a/assets/javascripts/discourse/initializers/discourse-voting.js.es6
+++ b/assets/javascripts/discourse/initializers/discourse-voting.js.es6
@@ -9,11 +9,17 @@ export default {
       if (siteSettings.voting_enabled) {
         api.addNavigationBarItem({
           name: "votes",
+          before: "top",
           customFilter: category => {
-            return category && category && category.can_vote;
+            return category && category.can_vote;
           },
           customHref: (category, args) => {
             return `${Discourse.BaseUri}/${args.filterMode}?order=votes`;
+          },
+          forceActive: (category, args, router) => {
+            return (
+              router.currentURL && router.currentURL.indexOf("order=votes") > -1
+            );
           }
         });
       }

GitHub sha: 16718b11

1 Like