         self.configureAlertView()
     }
 
+    public override func viewWillDisappear(_ animated: Bool) {
+        super.viewWillDisappear(animated)
+        self.textFields?.first?.resignFirstResponder()
+    }
+
     public override var preferredStatusBarStyle: UIStatusBarStyle {
         return self.presentingViewController?.preferredStatusBarStyle ?? .default
     }

    }

    // MARK: - Private

    private func listenForKeyboardChanges() {
        NotificationCenter.default.addObserver(self, selector: #selector(keyboardChange),

    private func commonInit() {
        self.modalPresentationStyle = .custom
        self.transitioningDelegate = self.transitionDelegate

        if self.preferredStyle == .alert {
            let command = UIKeyCommand(input: "\r", modifierFlags: [],
                                       action: #selector(self.handleHardwareReturnKey))
            self.addKeyCommand(command)
        }
    }

    // MARK: - Public
