From 7a0f07c2f6d019326d1b3f79e1a9fca25fd6214b Mon Sep 17 00:00:00 2001 From: Yuping Zuo Date: Thu, 17 Jan 2019 14:16:27 +0800 Subject: [PATCH 1/2] 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 864ff7804813..3268db021108 100644 --- a/src/sap.m/src/sap/m/SelectDialog.js +++ b/src/sap.m/src/sap/m/SelectDialog.js @@ -1066,7 +1066,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; @@ -1112,7 +1125,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()); From beb566804e19512d4858b993dd9978d5f700602e Mon Sep 17 00:00:00 2001 From: Yuping Zuo Date: Fri, 18 Jan 2019 15:23:36 +0800 Subject: [PATCH 2/2] Fixed eslint error --- src/sap.m/src/sap/m/SelectDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sap.m/src/sap/m/SelectDialog.js b/src/sap.m/src/sap/m/SelectDialog.js index 3268db021108..3367e35c9a85 100644 --- a/src/sap.m/src/sap/m/SelectDialog.js +++ b/src/sap.m/src/sap/m/SelectDialog.js @@ -1069,7 +1069,7 @@ function( press: function() { this.clearSelection(); if (!this.getMultiSelect()) { - fnClearAfterClose = function () { + var fnClearAfterClose = function () { this._oSelectedItem = this._oList.getSelectedItem(); this._aSelectedItems = this._oList.getSelectedItems();