Skip to content

Commit 1d15048

Browse files
fix: Ensure we're referencing up-to-date swipe state when configuring interaction enabled (#595)
For https://block.atlassian.net/browse/UI-9091 This resolves an issue where a cell would not respond to taps after the "full swipe" swipe action trigger. The issue was that we were referencing stale swipe state when configuring `isUserInteractionEnabled`. It was quite unintuitive when debugging this, but the line `swipeState = state` immediately resulted in those variables holding different values while processing the swipe action 🙃. We would incorrectly fall into the `.willPerformFirstActionAutomatically` case, making the content view unresponsive, despite the `swipeState` reporting as `.closed`. The SwipeActionsViewController has also been updated to demonstrate this is now working as expected. ### Checklist Please do the following before merging: - [ ] Ensure any public-facing changes are reflected in the [changelog](https://github.com/square/Listable/blob/main/CHANGELOG.md). Include them in the `Main` section.
1 parent c60f018 commit 1d15048

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
### Fixed
44

5+
- Fixed an issue where a full swipe of a swipe action could result in the cell being temporarily unresponsive.
6+
57
### Added
68

79
### Removed

Development/Sources/Demos/Demo Screens/SwipeActionsViewController.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@ final class SwipeActionsViewController: UIViewController {
333333
.inset(uniform: 16)
334334
}
335335
.accessibilityElement(label: "Swipeable Item", value: item.title, traits: [.button])
336+
.tappable {
337+
print("Tapped \(item.title)")
338+
}
336339
}
337340
}
338341

ListableUI/Sources/Internal/ItemCell.ContentViewContainer.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,11 @@ extension ItemCell {
286286
private func set(state: SwipeActionState, animated: Bool = false) {
287287
swipeState = state
288288

289+
// Warning! : `swipeState` may be mutated to a new value via it's property
290+
// observers and may not equal `state` at this point!
291+
289292
// We don't want any actions on the content view while our swipe actions are open.
290-
self.contentView.isUserInteractionEnabled = switch state {
293+
self.contentView.isUserInteractionEnabled = switch swipeState {
291294
case .closed:
292295
true
293296
case .expandActions, .open, .swiping, .willPerformFirstActionAutomatically:

0 commit comments

Comments
 (0)