Skip to content

Commit c0d27d1

Browse files
vRuslanmportuga
authored andcommitted
fix(ui-grid-menu-button.js): Click on the menu button item checkbox … (#6738)
* 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.
1 parent 60d0ac9 commit c0d27d1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/js/core/directives/ui-grid-menu-button.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ angular.module('ui.grid')
253253
function isColumnVisible(colDef) {
254254
return colDef.visible === true || colDef.visible === undefined;
255255
}
256+
257+
function getColumnIcon(colDef) {
258+
return isColumnVisible(colDef) ? 'ui-grid-icon-ok' : 'ui-grid-icon-cancel';
259+
}
256260

257261
// add header for columns
258262
showHideColumns.push({
@@ -267,15 +271,19 @@ angular.module('ui.grid')
267271
if ( colDef.enableHiding !== false ){
268272
// add hide menu item - shows an OK icon as we only show when column is already visible
269273
var menuItem = {
270-
icon: isColumnVisible(colDef) ? 'ui-grid-icon-ok' : 'ui-grid-icon-cancel',
274+
icon: getColumnIcon(colDef),
271275
action: function($event) {
272276
$event.stopPropagation();
273277

274278
service.toggleColumnVisibility( this.context.gridCol );
275279

276280
if ($event.target && $event.target.firstChild) {
277-
$event.target.firstChild.className = isColumnVisible(this.context.gridCol.colDef) ?
278-
'ui-grid-icon-ok' : 'ui-grid-icon-cancel';
281+
if (angular.element($event.target)[0].nodeName === 'I') {
282+
$event.target.className = getColumnIcon(this.context.gridCol.colDef);
283+
}
284+
else {
285+
$event.target.firstChild.className = getColumnIcon(this.context.gridCol.colDef);
286+
}
279287
}
280288
},
281289
shown: function() {

0 commit comments

Comments
 (0)