Skip to content

Fix OutlineList.setItems not reconfiguring cells for ContentEquatable items#66

Merged
Iron-Ham merged 1 commit into
mainfrom
Iron-Ham/fix-outline-content-reconfigure
Feb 23, 2026
Merged

Fix OutlineList.setItems not reconfiguring cells for ContentEquatable items#66
Iron-Ham merged 1 commit into
mainfrom
Iron-Ham/fix-outline-content-reconfigure

Conversation

@Iron-Ham
Copy link
Copy Markdown
Owner

Summary

  • Fix OutlineList.setItems (and any section snapshot apply path) not triggering cell reconfiguration when a CellViewModel conforms to ContentEquatable and content changes but identity stays the same

Root Cause

ListDataSource has two apply paths:

  1. Regular snapshot (apply(_ snapshot:)) — calls autoReconfigure to detect content changes
  2. Section snapshot (apply(_ sectionSnapshot:to:)) — passed directly to CollectionViewDiffableDataSource, bypassing autoReconfigure entirely

OutlineList.setItems uses path 2 (section snapshots for hierarchical data), so ContentEquatable checks never ran.

Fix

In ListDataSource.apply(_:to:animatingDifferences:), instead of forwarding the section snapshot directly to CollectionViewDiffableDataSource, build the full snapshot (same delete-old/append-new-visible-items logic) and route through the regular apply path. This naturally picks up autoReconfigure since self.apply calls it before forwarding.

Test Plan

  • Added autoReconfigureWorksWithSectionSnapshotApply — flat section snapshot with content change
  • Added autoReconfigureWithSectionSnapshotDetectsContentChanges — verifies identity matches but content differs
  • Added autoReconfigureWithHierarchicalSectionSnapshot — parent-child hierarchy with child content change
  • All 304 Lists tests pass
  • All ListKit tests pass

Fixes #65

@Iron-Ham Iron-Ham force-pushed the Iron-Ham/fix-outline-content-reconfigure branch 3 times, most recently from 4455dcb to 871edfb Compare February 23, 2026 22:24
Extract shared algorithms from ListDataSource and MixedListDataSource
into free functions (computeItemsToReconfigure, flattenSectionSnapshot),
introduce ListConfigurable protocol to eliminate convenience API
duplication across SimpleList/GroupedList/OutlineList, and remove dead
bridge methods superseded by the new protocol extension.

- Add ListConfigurable protocol with ~15 default implementations from
  4 requirements (collectionView, snapshot, itemIdentifier, indexPath)
- Extract computeItemsToReconfigure into AutoReconfigure.swift
- Extract flattenSectionSnapshot into AutoReconfigure.swift
- Remove dead ListConfigurationBridge methods (selectItem, deselectItem,
  isSelected, scrollToItem, scrollToTop, scrollToBottom)
- Add retain cycle guidance to configuration class doc comments
- Document @objc UIScrollViewDelegate forwarding duplication
- Add scrollToBottom pre-layout behavior note
- Use collectionView directly for numberOfItems/numberOfSections
@Iron-Ham Iron-Ham force-pushed the Iron-Ham/fix-outline-content-reconfigure branch from 871edfb to af3b3fc Compare February 23, 2026 22:37
@Iron-Ham Iron-Ham merged commit 7eaa28d into main Feb 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OutlineList.setItems does not reconfigure cells when content changes (ContentEquatable)

1 participant