Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit 8e9644b

Browse files
rewandygarrettmoon
authored andcommitted
Fix cell selection state issues (#3081)
Resolves #3037 This is a do-over of c85aa11, with the following differences: - Fixed `_ASTableViewCell` properties **always** being mutated to match corresponding `ASCellNode` passthrough properties, even when the hosted `ASCellNode` is currently `nil`. Now only inheriting passthrough properties when there’s an actual instance of `ASCellNode` to read them from. - Corrected spelling of `ASCellNode`’s `separatorInset` property. - Reverted `_ASCollectionViewCell` inheriting the hosted cell node’s `backgroundColor` & `clipsToBounds` properties. This seems to be surprising and unwanted behavior to some, as seen in #3053 and #3044. - Moved passthrough of `UITableViewCell`’s `selectedBackgroundView` into `_ASTableViewCell`’s `-setNode:` for consistency.
1 parent 30d4377 commit 8e9644b

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

AsyncDisplayKit/ASCellNode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) {
181181
*/
182182
@property (nonatomic) UITableViewCellAccessoryType accessoryType;
183183

184-
/* @abstract The seperator inset of the cell seperator line
184+
/* @abstract The inset of the cell separator line
185185
* ASTableView uses these properties when configuring UITableViewCells that host ASCellNodes.
186186
*/
187-
@property (nonatomic) UIEdgeInsets seperatorInset;
187+
@property (nonatomic) UIEdgeInsets separatorInset;
188188

189189
@end
190190

AsyncDisplayKit/ASTableView.mm

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,19 @@ - (void)setNode:(ASCellNode *)node
7777
{
7878
_node = node;
7979

80-
self.backgroundColor = node.backgroundColor;
81-
self.selectionStyle = node.selectionStyle;
82-
self.accessoryType = node.accessoryType;
83-
self.separatorInset = node.seperatorInset;
84-
self.clipsToBounds = node.clipsToBounds;
80+
if (node) {
81+
self.backgroundColor = node.backgroundColor;
82+
self.selectionStyle = node.selectionStyle;
83+
self.selectedBackgroundView = node.selectedBackgroundView;
84+
self.separatorInset = node.separatorInset;
85+
self.selectionStyle = node.selectionStyle;
86+
self.accessoryType = node.accessoryType;
87+
88+
// the following ensures that we clip the entire cell to it's bounds if node.clipsToBounds is set (the default)
89+
// This is actually a workaround for a bug we are seeing in some rare cases (selected background view
90+
// overlaps other cells if size of ASCellNode has changed.)
91+
self.clipsToBounds = node.clipsToBounds;
92+
}
8593

8694
[node __setSelectedFromUIKit:self.selected];
8795
[node __setHighlightedFromUIKit:self.highlighted];

AsyncDisplayKit/Details/_ASCollectionViewCell.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ - (void)setNode:(ASCellNode *)node
1717
ASDisplayNodeAssertMainThread();
1818
node.layoutAttributes = _layoutAttributes;
1919
_node = node;
20-
self.backgroundColor = node.backgroundColor;
21-
self.clipsToBounds = node.clipsToBounds;
20+
2221
[node __setSelectedFromUIKit:self.selected];
2322
[node __setHighlightedFromUIKit:self.highlighted];
2423
}

0 commit comments

Comments
 (0)