discourse/app
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
..
assets FIX: Nav items not recomputing on query param change (#12350) 2021-03-11 11:50:05 +10:00
controllers FIX: Do not add same email multiple times (#12322) 2021-03-10 14:49:26 +02:00
helpers A11Y: sets the html lang to user's locale when possible (#12007) 2021-02-10 16:12:09 +01:00
jobs FIX: Update excerpt after process_post (#12340) 2021-03-10 17:07:13 +00:00
mailers FIX: Skip sending PM email for user silence (#12240) 2021-03-02 09:18:09 +10:00
models DEV: support json_schema in theme settings (#12294) 2021-03-10 20:15:04 -05:00
serializers DEV: support json_schema in theme settings (#12294) 2021-03-10 20:15:04 -05:00
services FEATURE: Allow invites redemption with Omniauth providers. 2021-03-09 09:27:18 +08:00
views FIX: Remove unused JS from "finish installation" page (#12263) 2021-03-02 19:19:19 +01:00