Skip to content

Commit b68d4ff

Browse files
Merge pull request #105 from componentskit/fix-gestures-interactions
Fix `UKButton` and `UKCard` actions not triggered when parent has gesture recognizer
2 parents 217a852 + 9dc6c09 commit b68d4ff

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Sources/ComponentsKit/Components/Button/UKButton.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,13 @@ open class UKButton: FullWidthComponent, UKComponent {
199199
) {
200200
super.touchesCancelled(touches, with: event)
201201

202-
self.isPressed = false
202+
defer { self.isPressed = false }
203+
204+
if self.model.isInteractive,
205+
let location = touches.first?.location(in: self),
206+
self.bounds.contains(location) {
207+
self.action()
208+
}
203209
}
204210

205211
open override func traitCollectionDidChange(

Sources/ComponentsKit/Components/Card/UKCard.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,15 @@ open class UKCard<Content: UIView>: UIView, UKComponent {
170170
) {
171171
super.touchesCancelled(touches, with: event)
172172

173-
self.isPressed = false
173+
guard self.model.isTappable else { return }
174+
175+
defer { self.isPressed = false }
176+
177+
if self.model.isTappable,
178+
let location = touches.first?.location(in: self),
179+
self.bounds.contains(location) {
180+
self.onTap()
181+
}
174182
}
175183

176184
open override func traitCollectionDidChange(

0 commit comments

Comments
 (0)