From ea4b62939b3390f98c24cabeef42956d02a4e706 Mon Sep 17 00:00:00 2001 From: Peter <> Date: Wed, 19 Dec 2018 03:34:33 +0300 Subject: [PATCH] Fix trailing space when entering poll options --- TelegramUI/CreatePollOptionItem.swift | 18 ++++++++++-------- TelegramUI/ItemListControllerNode.swift | 4 +--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/TelegramUI/CreatePollOptionItem.swift b/TelegramUI/CreatePollOptionItem.swift index ca0ac71895..33204bf35a 100644 --- a/TelegramUI/CreatePollOptionItem.swift +++ b/TelegramUI/CreatePollOptionItem.swift @@ -161,15 +161,17 @@ class CreatePollOptionItemNode: ItemListRevealOptionsItemNode, ItemListItemNode, return false } if text.firstIndex(of: "\n") != nil { - let currentText = editableTextNode.attributedText?.string ?? "" - var updatedText = (currentText as NSString).replacingCharacters(in: range, with: text) - updatedText = updatedText.replacingOccurrences(of: "\n", with: " ") - if updatedText.count == 1 { - updatedText = "" + if text != "\n" { + let currentText = editableTextNode.attributedText?.string ?? "" + var updatedText = (currentText as NSString).replacingCharacters(in: range, with: text) + updatedText = updatedText.replacingOccurrences(of: "\n", with: " ") + 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 { next() } else { diff --git a/TelegramUI/ItemListControllerNode.swift b/TelegramUI/ItemListControllerNode.swift index bb6ee48840..c145c25dcc 100644 --- a/TelegramUI/ItemListControllerNode.swift +++ b/TelegramUI/ItemListControllerNode.swift @@ -419,9 +419,7 @@ class ItemListControllerNode: ASDisplayNode, UIScrollV } } } - if applied { - strongSelf.appliedFocusItemTag = focusItemTag - } + strongSelf.appliedFocusItemTag = focusItemTag } }