         defer { self.reloadTabs() }
         
         guard !newValue.isEmpty
-            && self.delegate?.tabsControl?(self, setTitle: newValue, forItem: tabButton.representedObject!) != nil else { return }
+            && self.delegate?.tabsControl?(self, setTitle: newValue, forItem: tabButton.representedObject!) != nil,
+            let selectedItemIndex = self.selectedItemIndex
+            else { return }
         
         // TODO add callback to client code to replace forwarding controlTextDidEndEditing(_:)
         
-        tabButton.representedObject = self.dataSource?.tabsControl(self, itemAtIndex: self.selectedItemIndex)
+        tabButton.representedObject = self.dataSource?.tabsControl(self, itemAtIndex: selectedItemIndex)
     }
 
     // MARK: - Drawing

                                   target: self,
                                   action: #selector(TabsControl.selectTab(_:)),
                                   style: style)
            
            button.editable = self.delegate?.tabsControl?(self, canEditTitleOfItem: item) == true


    }
    
    /// The index of the selected item.
    public var selectedItemIndex: Int? {
        guard let selectedButton = self.selectedButton
            else { return nil }
        return selectedButton.tag
    }
    
    /**
