rackt/react-router — pull request #388 by gaearon (2014-10-11 18:12:04+00:00)
Title: [added] <Route ignoreScrollBehavior /> to opt out of scroll behavior for itself and descendants

This PR adds `ignoreScrollBehavior` on `Route` component as [discussed](https://github.com/rackt/react-router/pull/326#issuecomment-58593491) in #326.

It seems to work on my project but I'd like to hear your opinions on **how I should approach testing**.
Should I unit-test `Routes`, `ScrollContext`, or what?

------------------

If you specify `ignoreScrollBehavior` on a route, scroll behavior will not be triggered when transitioning *within* that route. It *will*, however, be triggered when transitioning *outside* this route. This allows us to support a variety of scenarios where you might want scroll behavior to be ignored:

* Searching, where path is updated every time you change a query
* Tabs, where you'd rather not scroll to top when switching between them

In the first case, by specifying `ignoreScrollBehavior` on `search` route we ensure that transitions from `search` to `search` (which is what happens when you type a search query) will *not* trigger scroll behavior, but transitions from `search` to `home` and back will.

In the second case, by specifying `ignoreScrollBehavior` on `home` parent route, we say transitions *within* `home` (e.g. from `feed` to `discover` and back) don't trigger scroll behavior. However if you go from `feed` to `about`, scroll behavior will be respected.

```javascript

```

(I'll draw a better picture later :-)

![](https://cloud.githubusercontent.com/assets/810438/4585743/db9431f0-500a-11e4-9a47-b56116e28cf6.jpg)

By default, scroll behavior is performed on all transitions (red arrows). Routes can create “scrolling realms” for themselves and their descendants by specifying `ignoreScrollBehavior` (purple areas). Transitions that are fully confined to a single scrolling realm, don't have any scroll behavior performed (blue arrows). If transition is not fully confined to a scrolling realm, `scrollBehavior` of `Routes` is respected.