Skip to content

Commit 3085417

Browse files
MartijnWelkermportuga
authored andcommitted
fix(uiGridColumMenu): Check for menu item visibility before trying to focus the first visible menu item
1 parent 3a8e87b commit 3085417

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,15 @@ function ($timeout, gridUtil, uiGridConstants, uiGridColumnMenuService, $documen
397397
$timeout(function() {
398398
uiGridColumnMenuService.repositionMenu( $scope, $scope.col, $scope.colElementPosition, $elm, $scope.colElement );
399399

400+
var hasVisibleMenuItems = $scope.menuItems.some(function (menuItem) {
401+
return menuItem.shown();
402+
});
403+
400404
// automatically set the focus to the first button element in the now open menu.
401-
gridUtil.focus.bySelector($document, '.ui-grid-menu-items .ui-grid-menu-item:not(.ng-hide)', true);
405+
if (hasVisibleMenuItems) {
406+
gridUtil.focus.bySelector($document, '.ui-grid-menu-items .ui-grid-menu-item:not(.ng-hide)', true);
407+
}
408+
402409
delete $scope.colElementPosition;
403410
delete $scope.columnElement;
404411
addKeydownHandlersToMenu();

0 commit comments

Comments
 (0)