This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse
Martin Brennan b81bb2f93b
FIX: Nav items not recomputing on query param change (#12350)
The recalculation of the `forceActive` function for the nav items was being run _before_ the querystring parameters are getting updated. For example for the Unassigned link:

```javascript
i.addNavigationBarItem({
  name: "unassigned",
  customFilter: (category) => {
    return category && category.enable_unassigned_filter;
  },
  customHref: (category) => {
    if (category) {
      return getURL(category.url) + "/l/latest?status=open&assigned=nobody";
    }
  },
  forceActive: (category, args, router) => {
    const queryParams = router.currentRoute.queryParams;

    return (
      queryParams &&
      Object.keys(queryParams).length === 2 &&
      queryParams["assigned"] === "nobody" &&
      queryParams["status"] === "open"
    );
  },
  before: "top",
});
```

When forceActive is hit going from e.g.`http://localhost:3000/c/some-category/5/l/top` to `http://localhost:3000/c/some-category/5/l/latest?assigned=nobody&status=open` the `queryParams` are empty and the URL does not seem to change until after the transition and so `active` ends up being false in this `navigation-item` function which controls whether or not to do the highlight:

```javascript
@discourseComputed("content.filterType", "filterType", "content.active")
active(contentFilterType, filterType, active) {
  if (active !== undefined) {
    return active;
  }
  return contentFilterType === filterType;
},
```

Also sometimes this is not even recalculated, for example going from `http://localhost:3000/c/some-category/5/l/latest?status=open` to `http://localhost:3000/c/some-category/5/l/latest?assigned=nobody&status=open`. This PR fixes the issue where the query parameters changing was not forcing this recalculation. This was especially noticable in conjunction with https://github.com/discourse/discourse-loading-slider.
2021-03-11 11:50:05 +10:00
..
app FIX: Nav items not recomputing on query param change (#12350) 2021-03-11 11:50:05 +10:00
config DEV: Use Ember CLI middleware to decorate the index template (#12292) 2021-03-09 10:09:35 -05:00
lib/bootstrap-json DEV: Use Ember CLI middleware to decorate the index template (#12292) 2021-03-09 10:09:35 -05:00
public/assets/scripts DEV: Use Ember CLI middleware to decorate the index template (#12292) 2021-03-09 10:09:35 -05:00
tests UX: pasting a twitter link into composer title will not set the title (#12332) 2021-03-10 15:49:56 -05:00
.ember-cli REFACTOR: Sync up master with changes for Ember-CLI (#11671) 2021-01-12 10:13:21 -05:00
ember-cli-build.js DEV: Use Ember CLI middleware to decorate the index template (#12292) 2021-03-09 10:09:35 -05:00
package.json DEV: Use Ember CLI middleware to decorate the index template (#12292) 2021-03-09 10:09:35 -05:00
testem.js Sync up master and Ember CLI branches again (#11746) 2021-01-18 16:12:45 -05:00
yarn.lock DEV: Migrate to Ember CLI (#11932) 2021-02-03 14:22:20 -05:00