sproutcore/sproutcore — Issue #612: Vertical scrollbar for ListView does not update when backed by a regular content array
Author: hungle
Created: 2011-10-10 03:19:08+00:00
State: open

When used with SC.ScrollView, the vertical scrollbar does not get updated when a ListView is binded to an SC.ArrayController who's content is set to a regular content array and not a RecordArray from SC.Store. The ListView updates correctly up until the visible area of the list is filled. It seems like 'updateContentRangeObserver' function on the CollectionView only registers to observe any changes to the 'nowShowing' index set and anything that is not visible/currently renderable on the list will not cause the list to update.

This makes sense since SC.CollectionView only cares about rendering the visible area. After several hours of digging and tearing my hair out, I traced the problem to SC.ScrollView depending on the 'calculatedHeight' property on the CollectionView to determine whether the vertical scrollbar needs to be updated. Currently the 'calculatedHeight' property is computed by the 'computeLayout' function (at least for SC.ListView) which only gets called if 'reloadIfNeeded' is called at the end of the run loop. This last part is the key since 'reloadIfNeeded' is only scheduled to run if the window resizes or if the 'nowShowing' set changes.

When using SC.RecordArray backed by the store, the entire index set is invalidated through the '_storeKeysDidChange' function which will lead to a proper update on the ListView. Also it seems like this problem exists at least all the way back to SC 1.4.