From c0d27d1fffb491a451116c98e98b2d710c2074b6 Mon Sep 17 00:00:00 2001 From: Ruslan Vasyunin Date: Thu, 31 May 2018 18:12:53 +0200 Subject: [PATCH] =?UTF-8?q?fix(ui-grid-menu-button.js):=20=20Click=20on=20?= =?UTF-8?q?the=20menu=20button=20item=20checkbox=20=E2=80=A6=20(#6738)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(ui-grid-menu-button.js): Click on the menu button item checkbox weird behavior * chore(ui-grid-menu-button): Add function for icon Reduce duplication of code. --- src/js/core/directives/ui-grid-menu-button.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/js/core/directives/ui-grid-menu-button.js b/src/js/core/directives/ui-grid-menu-button.js index 1bf1f6836a..f8288500f0 100644 --- a/src/js/core/directives/ui-grid-menu-button.js +++ b/src/js/core/directives/ui-grid-menu-button.js @@ -253,6 +253,10 @@ angular.module('ui.grid') function isColumnVisible(colDef) { return colDef.visible === true || colDef.visible === undefined; } + + function getColumnIcon(colDef) { + return isColumnVisible(colDef) ? 'ui-grid-icon-ok' : 'ui-grid-icon-cancel'; + } // add header for columns showHideColumns.push({ @@ -267,15 +271,19 @@ angular.module('ui.grid') if ( colDef.enableHiding !== false ){ // add hide menu item - shows an OK icon as we only show when column is already visible var menuItem = { - icon: isColumnVisible(colDef) ? 'ui-grid-icon-ok' : 'ui-grid-icon-cancel', + icon: getColumnIcon(colDef), action: function($event) { $event.stopPropagation(); service.toggleColumnVisibility( this.context.gridCol ); if ($event.target && $event.target.firstChild) { - $event.target.firstChild.className = isColumnVisible(this.context.gridCol.colDef) ? - 'ui-grid-icon-ok' : 'ui-grid-icon-cancel'; + if (angular.element($event.target)[0].nodeName === 'I') { + $event.target.className = getColumnIcon(this.context.gridCol.colDef); + } + else { + $event.target.firstChild.className = getColumnIcon(this.context.gridCol.colDef); + } } }, shown: function() {