From 301ead74474f52670eac2d3945e88dbf2608f092 Mon Sep 17 00:00:00 2001 From: vasavk Date: Wed, 28 Feb 2024 22:03:17 +0530 Subject: [PATCH 1/2] Digital ACT-191 ONEAPP-6682 story: Fix for the observed crash on removing last char when having char counter and exceeded limit. --- VDS/Components/TextFields/TextArea/TextArea.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/VDS/Components/TextFields/TextArea/TextArea.swift b/VDS/Components/TextFields/TextArea/TextArea.swift index 92f5525a..432d24bd 100644 --- a/VDS/Components/TextFields/TextArea/TextArea.swift +++ b/VDS/Components/TextFields/TextArea/TextArea.swift @@ -300,12 +300,11 @@ extension TextArea: UITextViewDelegate { //The exceeding characters will be highlighted to help users correct their entry. if ((maxLength ?? 0) > 0) { if textView.text.count <= allowCharCount { + highlightCharacterOverflow() + //setting the value and firing control event value = textView.text sendActions(for: .valueChanged) - if (textView.text.count > (maxLength ?? 0)) { - highlightCharacterOverflow() - } } else { textView.text.removeLast() highlightCharacterOverflow() From a4582f11a597b50af9bd082500819f256c61e504 Mon Sep 17 00:00:00 2001 From: vasavk Date: Thu, 29 Feb 2024 00:45:54 +0530 Subject: [PATCH 2/2] Digital ACT-191 ONEAPP-6682 story: fixed the bug dealing with the character counter --- VDS/Components/TextFields/TextArea/TextArea.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/VDS/Components/TextFields/TextArea/TextArea.swift b/VDS/Components/TextFields/TextArea/TextArea.swift index 432d24bd..8e5f8e58 100644 --- a/VDS/Components/TextFields/TextArea/TextArea.swift +++ b/VDS/Components/TextFields/TextArea/TextArea.swift @@ -251,7 +251,7 @@ open class TextArea: EntryFieldBase { return countStr } else { showError = false - errorText = "" + errorText = nil return ("\(countStr)" + "/" + "\(maxLength ?? 0)") } } else { @@ -261,7 +261,7 @@ open class TextArea: EntryFieldBase { open func highlightCharacterOverflow() { let count = textView.text.count - guard let maxLength, count > maxLength else { + guard let maxLength, maxLength > 0, count > maxLength else { textView.textAttributes = nil return } @@ -315,6 +315,7 @@ extension TextArea: UITextViewDelegate { sendActions(for: .valueChanged) } } + } /// Will move this into a new file, need to talk with Scott/Kyle