Fix trailing space when entering poll options

This commit is contained in:
Peter 2018-12-19 03:34:33 +03:00
parent 59e2607e08
commit ea4b62939b
2 changed files with 11 additions and 11 deletions

View File

@ -161,15 +161,17 @@ class CreatePollOptionItemNode: ItemListRevealOptionsItemNode, ItemListItemNode,
return false return false
} }
if text.firstIndex(of: "\n") != nil { if text.firstIndex(of: "\n") != nil {
let currentText = editableTextNode.attributedText?.string ?? "" if text != "\n" {
var updatedText = (currentText as NSString).replacingCharacters(in: range, with: text) let currentText = editableTextNode.attributedText?.string ?? ""
updatedText = updatedText.replacingOccurrences(of: "\n", with: " ") var updatedText = (currentText as NSString).replacingCharacters(in: range, with: text)
if updatedText.count == 1 { updatedText = updatedText.replacingOccurrences(of: "\n", with: " ")
updatedText = "" if updatedText.count == 1 {
updatedText = ""
}
let updatedAttributedText = NSAttributedString(string: updatedText, font: Font.regular(17.0), textColor: item.theme.list.itemPrimaryTextColor)
self.textNode.attributedText = updatedAttributedText
self.editableTextNodeDidUpdateText(editableTextNode)
} }
let updatedAttributedText = NSAttributedString(string: updatedText, font: Font.regular(17.0), textColor: item.theme.list.itemPrimaryTextColor)
self.textNode.attributedText = updatedAttributedText
self.editableTextNodeDidUpdateText(editableTextNode)
if let next = item.next { if let next = item.next {
next() next()
} else { } else {

View File

@ -419,9 +419,7 @@ class ItemListControllerNode<Entry: ItemListNodeEntry>: ASDisplayNode, UIScrollV
} }
} }
} }
if applied { strongSelf.appliedFocusItemTag = focusItemTag
strongSelf.appliedFocusItemTag = focusItemTag
}
} }
} }