karelia/iMedia — Issue #39: Nodes tree view falsely scrolls on node expansion
Author: jjac
Created: 2012-01-11 14:58:31+00:00
State: open

### Steps to reproduce

This false behavior may happen on two occasions:

- Select a node, scroll down to some other distant node, expand it and the browser will scroll back to the original node
- Make sure no node is selected (e.g. expand and collapse a node that is the direct ancestor of a selected node). Then scroll down to some other distant node, expand it and the browser will scroll to the direct ancestor of the expanded node - possibly scrolling the just expanded node out of the visible area.

### Expected behavior

When expanding a node the scroll position of the surrounding view should stay in the area so that the user can watch the effect of the expansion.

### Code Analysis

The first behavior mentioned is due to a side effect of selectNode: which will be called when the expanded state is restored in

- [IMBNodeViewController _nodesDidChange]

The second behavior mentioned is due to a side effect of a recent change in

-[IMBLibraryController _replaceNode:(IMBNode*)inOldNode withNode:(IMBNode*)inNewNode parentNodeIdentifier:(NSString*)inParentNodeIdentifier]

in which a workaround was implemented to avoid a 'nasty crashing bug' (see lines 710ff):

[parentNode setSubNodes:nil];	// Important workaround. Do not remove!

This workaround causes the NSOutlineView to scroll to parentNode.

### Suggested Fix

After aeons of analyzing the control flow involved I found the fix to be a simple save/restore pattern of the current scroll position (to be inserted at the right places). I intend to deliver the fix along with the upcoming Photo Stream pull request.