 
     override func viewWillDisappear(_ animated: Bool) {
         super.viewWillDisappear(animated)
-        guard let dismissHandler = dismissHandler, !discardDismissHandlerOnPrimaryButtonTap else {
+        guard let dismissHandler = dismissHandler else {
+            return
+        }
+        guard !(discardDismissHandlerOnPrimaryButtonTap && primaryButtonTapped) else {
             return
         }
         dismissHandler()
+    }
+    
+    override func viewDidDisappear(_ animated: Bool) {
+        super.viewDidDisappear(animated)
+        primaryButtonTapped = false
     }
     
     func apply(theme: Theme) {

    fileprivate var dismissHandler: ScrollableEducationPanelDismissHandler?
    fileprivate var showCloseButton = true
    private var discardDismissHandlerOnPrimaryButtonTap = false
    
    var image:UIImage? {
        get {

        guard let primaryButtonTapHandler = primaryButtonTapHandler else {
            return
        }
        primaryButtonTapped = true
        primaryButtonTapHandler(sender)
    }

