Skip to Content
Oct 15, 2019 at 03:41 PM

ComboBox attachChange


Hello everyone,

I am using Combobox in SAPUI5, but recently facing a problem, hope someone can help me!
Based on the documentation an event change is fired when:

  • The focus leaves the text input field
  • The Enter key is pressed
  • In addition, this event is also fired when an item in the list is selected.

Unfortunately the last one is not working in my case. What exactly happens is that when I click with mouse the list is closed and the name is selected correctly, but the cursor is still pulsing so the text input of the ComboBox is still focused.

Here you have my code:

var languageComboBox = new sap.m.ComboBox();
//Add items to languageComboBox: 

for (var i in data.locales){ 

var currentItem = data.locales[i]; 

if (currentItem.enabled) 

languageComboBox.addItem(new sap.ui.core.Item({, text: currentItem.label}));

languageComboBox.attachChange(function(oEvent) {
var oSelectedItem = languageComboBox.getSelectedItem(); 
var sItemKey = oSelectedItem.getKey(); 

var sItemText = oSelectedItem.getText();.........

PS. .attachChange works correctly if there are two other cases happening.