From 8687516645523174b2eec80c172c70bb26beb356 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 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/sap.m/src/sap/m/SelectDialog.js b/src/sap.m/src/sap/m/SelectDialog.js index fffbdc59086e..b13b8d436672 100644 --- a/src/sap.m/src/sap/m/SelectDialog.js +++ b/src/sap.m/src/sap/m/SelectDialog.js @@ -1017,7 +1017,19 @@ function( press: function() { this._removeSelection(); this._updateSelectionIndicator(); - this._oDialog.focus(); + if (this.getMultiSelect()) { + this._oDialog.focus(); + } else { + 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) }); } @@ -1064,7 +1076,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());