     
     public func updateRightButtonText(_ newText: String?) {
         
+        
+        
         if let barButtonItems = textViewToolbar.items, let newText = newText {
             
-            rightButtonText = newText
-            
             var updatedBarButtonItems : [UIBarButtonItem] = []
-            let rightBarButton: UIBarButtonItem = UIBarButtonItem(title: newText, style: .done, target: self, action:#selector(rightButtonAction))
-            
             updatedBarButtonItems.append(barButtonItems[0])
             updatedBarButtonItems.append(barButtonItems[1])
+            
+            // clear current toolbar.
+            textViewToolbar.items = nil;
+            
+            // build the updated right hand button.
+            rightButtonText = newText
+            
+            //let rightBarButton: UIBarButtonItem = UIBarButtonItem(title: newText, style: .done, target: self, action:#selector(rightButtonAction))
+            var rightBarButton: UIBarButtonItem = UIBarButtonItem()
+            
+            if let rightButtonText = rightButtonText {
+                rightBarButton = generateRightBarButton(rightButtonText)
+            }
+            
+//            rightBarButton.target = self
+//            rightBarButton.action = #selector(rightButtonAction)
+//
+            
             updatedBarButtonItems.append(rightBarButton)
             
             textViewToolbar.items = updatedBarButtonItems

            leftButtonText = newText
            
            var updatedBarButtonItems : [UIBarButtonItem] = []
            let leftBarButton: UIBarButtonItem = UIBarButtonItem(title: newText, style: .done, target: self, action:#selector(leftButtonAction))
            
            if showMaxCount ?? false {
                leftBarButton.isEnabled = false
            } else {
                leftBarButton.isEnabled = true
            }
            
            updatedBarButtonItems.append(leftBarButton)
            updatedBarButtonItems.append(barButtonItems[1])
            updatedBarButtonItems.append(barButtonItems[2])
            
            textViewToolbar.items = updatedBarButtonItems
            textViewToolbar.sizeToFit()
            

        var barButtonItems : [UIBarButtonItem] = []
    
        textViewToolbar.barStyle = .default
        textViewToolbar.barTintColor = UIColor.white
        
        let flexSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
        
        if let leftButtonText = leftButtonText {
            let leftBarButton = generateLeftBarButton(leftButtonText)
            
            // Logic to control the enabled/disabled state depending on whether we are showing a counter
            // or a proper button.
            
            if showMaxCount ?? false {
                leftBarButton.isEnabled = false
