Skip to content

Commit 33416fc

Browse files
committed
sap.m.SelectDialog: Allow clear in single selection
The clear button is always enabled now, if showClearButton=true and multiSelect=false. The clear button behavior is redefined to act as clear+confirm in single selection mode.
1 parent ccdea50 commit 33416fc

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/sap.m/src/sap/m/SelectDialog.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,20 @@ function(
10521052
if (!this._oClearButton) {
10531053
this._oClearButton = new Button(this.getId() + "-clear", {
10541054
text: this._oRb.getText("SELECTDIALOG_CLEARBUTTON"),
1055-
press: this.clearSelection.bind(this)
1055+
press: function() {
1056+
this.clearSelection();
1057+
if (!this.getMultiSelect()) {
1058+
fnClearAfterClose = function () {
1059+
this._oSelectedItem = this._oList.getSelectedItem();
1060+
this._aSelectedItems = this._oList.getSelectedItems();
1061+
1062+
this._oDialog.detachAfterClose(fnClearAfterClose);
1063+
this._fireConfirmAndUpdateSelection();
1064+
}.bind(this);
1065+
this._oDialog.attachAfterClose(fnClearAfterClose);
1066+
this._oDialog.close();
1067+
}
1068+
}.bind(this)
10561069
});
10571070
}
10581071
return this._oClearButton;
@@ -1098,7 +1111,7 @@ function(
10981111
oInfoBar = this._oList.getInfoToolbar();
10991112

11001113
if (this.getShowClearButton() && this._oClearButton) {
1101-
this._oClearButton.setEnabled(iSelectedContexts > 0);
1114+
this._oClearButton.setEnabled(iSelectedContexts > 0 || !this.getMultiSelect());
11021115
}
11031116
// update the selection label
11041117
oInfoBar.setVisible(!!iSelectedContexts && this.getMultiSelect());

0 commit comments

Comments
 (0)