Skip to content

Commit 239ea10

Browse files
awolfishGerrit Code Review
authored and
Gerrit Code Review
committed
Merge "[FIX] sap.ui.commons.DropDownBox: Selection of the ListBox items work onclick."
2 parents 717ccea + 9844534 commit 239ea10

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/sap.ui.commons/src/sap/ui/commons/DropdownBox.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,25 @@ sap.ui.define(['jquery.sap.global', './ComboBox', './library', 'sap/ui/core/Hist
13051305

13061306
};
13071307

1308+
/**
1309+
* Focuses the dropdown upon inner ListBox#click.
1310+
* As there might be raise condition between the dropdown.focus and listbox.click events for some browsers.
1311+
* this method makes sure the events are in the right order (listbox#click->dropdown#focus)
1312+
* @private
1313+
*/
1314+
DropdownBox.prototype._focusAfterListBoxClick = function() {
1315+
if (!sap.ui.Device.browser.webkit) {
1316+
this.focus();
1317+
} else {
1318+
var oLB = this._getListBox();
1319+
oLB.addDelegate({
1320+
onclick: function() {//this will be executed after the ListBox#onclick handler
1321+
oLB.removeDelegate(this);
1322+
this.focus();
1323+
}.bind(this)});
1324+
}
1325+
};
1326+
13081327
/*
13091328
* Handle the sapfocusleave pseudo event and ensure that when the focus moves to the list box,
13101329
* the check change functionality (incl. fireChange) is not triggered.
@@ -1316,7 +1335,7 @@ sap.ui.define(['jquery.sap.global', './ComboBox', './library', 'sap/ui/core/Hist
13161335

13171336
var oLB = this._getListBox();
13181337
if (oEvent.relatedControlId && jQuery.sap.containsOrEquals(oLB.getFocusDomRef(), sap.ui.getCore().byId(oEvent.relatedControlId).getFocusDomRef())) {
1319-
this.focus();
1338+
this._focusAfterListBoxClick();
13201339
} else {
13211340
// we left the DropdownBox to another (unrelated) control and thus have to fire the change (if needed).
13221341
if (this.oPopup && this.oPopup.isOpen()) {

src/sap.ui.commons/test/sap/ui/commons/DropdownBox.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,23 @@
348348

349349
oLyt.createRow(oLabel, oDdB, oTextView);
350350

351+
oLabel = new sap.ui.commons.Label({text: "Dropdown with histroy of 5 elements", labelFor: "ddb-history"});
352+
var ddbHistory = new sap.ui.commons.DropdownBox("ddb-history"),
353+
oTextView = new sap.ui.commons.TextView("TV12"),
354+
allScen = ['A','B','C','D','E','F0','F1','F3','G','H','I','J','K','L','M','N'],
355+
aLBItems = [];
356+
357+
for (var i = 0; i < allScen.length; i++) {
358+
var item = new sap.ui.core.ListItem();
359+
item.setText(allScen[i]);
360+
item.setKey(allScen[i]);
361+
ddbHistory.addItem(item);
362+
}
363+
ddbHistory.setMaxHistoryItems(5);
364+
ddbHistory.attachChange(function() {oTextView.setText("Event: Change, selected item [" + ddbHistory.getSelectedKey() + "]");});
365+
366+
oLyt.createRow(oLabel, ddbHistory, oTextView);
367+
351368
</script>
352369
</head>
353370
<body class="sapUiBody" role="application">

0 commit comments

Comments
 (0)