Filter newline characters from the "textField(_: shouldChangeCharactersIn: replacementString: )" function in the InputAlertView component for the Browse module.

This commit is contained in:
Javier Cicchelli 2022-12-20 02:09:19 +01:00
parent b77f1b758c
commit 5aeec04e19

View File

@ -118,10 +118,16 @@ extension InputAlertView {
// MARK: UITextFieldDelegate // MARK: UITextFieldDelegate
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { func textField(
_ textField: UITextField,
shouldChangeCharactersIn range: NSRange,
replacementString string: String
) -> Bool {
component.textFieldString = { component.textFieldString = {
if let text = textField.text as NSString? { if let text = textField.text as NSString? {
return text.replacingCharacters(in: range, with: string) return text
.replacingCharacters(in: range, with: string)
.trimmingCharacters(in: .newlines)
} else { } else {
return .empty return .empty
} }