From 33416fc18adb75fbeb7777d5df672f01012b1f62 Mon Sep 17 00:00:00 2001 From: Yuping Zuo Date: Thu, 17 Jan 2019 14:16:27 +0800 Subject: [PATCH] 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. --- src/sap.m/src/sap/m/SelectDialog.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/sap.m/src/sap/m/SelectDialog.js b/src/sap.m/src/sap/m/SelectDialog.js index b83c23ef8f0c..4f27d1d04d32 100644 --- a/src/sap.m/src/sap/m/SelectDialog.js +++ b/src/sap.m/src/sap/m/SelectDialog.js @@ -1052,7 +1052,20 @@ function( if (!this._oClearButton) { this._oClearButton = new Button(this.getId() + "-clear", { text: this._oRb.getText("SELECTDIALOG_CLEARBUTTON"), - press: this.clearSelection.bind(this) + press: function() { + this.clearSelection(); + if (!this.getMultiSelect()) { + fnClearAfterClose = function () { + this._oSelectedItem = this._oList.getSelectedItem(); + this._aSelectedItems = this._oList.getSelectedItems(); + + this._oDialog.detachAfterClose(fnClearAfterClose); + this._fireConfirmAndUpdateSelection(); + }.bind(this); + this._oDialog.attachAfterClose(fnClearAfterClose); + this._oDialog.close(); + } + }.bind(this) }); } return this._oClearButton; @@ -1098,7 +1111,7 @@ function( oInfoBar = this._oList.getInfoToolbar(); if (this.getShowClearButton() && this._oClearButton) { - this._oClearButton.setEnabled(iSelectedContexts > 0); + this._oClearButton.setEnabled(iSelectedContexts > 0 || !this.getMultiSelect()); } // update the selection label oInfoBar.setVisible(!!iSelectedContexts && this.getMultiSelect());