     fileprivate var elements = [String]() {
         didSet {
             tableView.reloadData()
-            updateFrame()
+            height = tableView.contentSize.height
+        }
+    }
+    private var heightConstraint: NSLayoutConstraint?
+    private var height: CGFloat = 0 {
+        didSet {
+            guard height != oldValue else {
+                return
+            }
+
+            guard let superview = superview else {
+                heightConstraint?.constant = (height > maximumHeight) ? maximumHeight : height
+                return
+            }
+
+            superview.layoutIfNeeded()
+            UIView.animate(withDuration: 0.2) {
+                self.heightConstraint?.constant = (self.height > self.maximumHeight) ? self.maximumHeight : self.height
+                superview.layoutIfNeeded()
+            }
         }
     }
 

            textField.addTarget(self, action: #selector(textFieldEditingChanged), for: .editingChanged)
            textField.addTarget(self, action: #selector(textFieldEditingEnded), for: .editingDidEnd)

            updateFrame()
        }
    }
    /** A `LUAutocompleteTableViewCell` subclass that will be used to show a text suggestion.

    }

    @objc private func textFieldEditingEnded() {
        height = 0
    }
}

