Skip to content

Commit

Permalink
fix(uiGridColumMenu): Check for menu item visibility before trying to…
Browse files Browse the repository at this point in the history
… focus the first visible menu item
  • Loading branch information
MartijnWelker authored and mportuga committed Dec 19, 2018
1 parent 3a8e87b commit 3085417
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/js/core/directives/ui-grid-column-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,15 @@ function ($timeout, gridUtil, uiGridConstants, uiGridColumnMenuService, $documen
$timeout(function() {
uiGridColumnMenuService.repositionMenu( $scope, $scope.col, $scope.colElementPosition, $elm, $scope.colElement );

var hasVisibleMenuItems = $scope.menuItems.some(function (menuItem) {
return menuItem.shown();
});

// automatically set the focus to the first button element in the now open menu.
gridUtil.focus.bySelector($document, '.ui-grid-menu-items .ui-grid-menu-item:not(.ng-hide)', true);
if (hasVisibleMenuItems) {
gridUtil.focus.bySelector($document, '.ui-grid-menu-items .ui-grid-menu-item:not(.ng-hide)', true);
}

delete $scope.colElementPosition;
delete $scope.columnElement;
addKeydownHandlersToMenu();
Expand Down

0 comments on commit 3085417

Please sign in to comment.