Skip to content

Commit

Permalink
fix: unmask when removed from hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
ioannisj committed Dec 5, 2024
1 parent 74dd9a9 commit f62f070
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions PostHog/PostHogMaskViewModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,24 @@
}

private class PostHogMaskViewTaggerView: UIView {
override func didMoveToSuperview() {
super.didMoveToSuperview()
weak private var maskedView: UIView?
override func layoutSubviews() {
super.layoutSubviews()
// ### Why grandparent view?
//
// Because of SwiftUI-to-UIKit view bridging:
// OriginalView (SwiftUI) <- we tag here
// L PostHogMaskViewTagger (ViewRepresentable)
// L PostHogMaskViewTaggerView (UIView) <- we are here
maskedView = superview?.superview
superview?.superview?.postHogNoCapture = true
}

override func removeFromSuperview() {
super.removeFromSuperview()
maskedView?.postHogNoCapture = false
maskedView = nil
}
}

extension UIView {
Expand Down

0 comments on commit f62f070

Please sign in to comment.