Skip to content

Commit

Permalink
Merge pull request #141 from rizwan95/master
Browse files Browse the repository at this point in the history
Tokenize text field in textFieldDidEndEditing
  • Loading branch information
ricardopereira committed May 29, 2020
2 parents 46b1500 + 79df526 commit 9cf04be
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Source/WSTagsField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ open class WSTagsField: UIScrollView {
tagViews.forEach { $0.displayDelimiter = self.isDelimiterVisible ? self.delimiter : "" }
}
}

/// Whether the text field should tokenize strings automatically when the keyboard is dismissed.
open var shouldTokenizeAfterResigningFirstResponder: Bool = false

open var maxHeight: CGFloat = CGFloat.infinity {
didSet {
Expand Down Expand Up @@ -794,6 +797,9 @@ extension WSTagsField: UITextFieldDelegate {
}

public func textFieldDidEndEditing(_ textField: UITextField) {
if !isTextFieldEmpty, shouldTokenizeAfterResigningFirstResponder {
tokenizeTextFieldText()
}
textDelegate?.textFieldDidEndEditing?(textField)
}

Expand Down

0 comments on commit 9cf04be

Please sign in to comment.