|
726 | 726 | };
|
727 | 727 | }]);
|
728 | 728 |
|
729 |
| - module.directive('uiGridRenderContainer', ['$timeout', '$document', 'gridUtil', 'uiGridConstants', 'uiGridCellNavService', '$compile', |
730 |
| - function ($timeout, $document, gridUtil, uiGridConstants, uiGridCellNavService, $compile) { |
| 729 | + module.directive('uiGridRenderContainer', ['$timeout', '$document', 'gridUtil', 'uiGridConstants', 'uiGridCellNavService', '$compile','uiGridCellNavConstants', |
| 730 | + function ($timeout, $document, gridUtil, uiGridConstants, uiGridCellNavService, $compile, uiGridCellNavConstants) { |
731 | 731 | return {
|
732 | 732 | replace: true,
|
733 | 733 | priority: -99999, //this needs to run very last
|
|
755 | 755 | uiGridCellNavService.decorateRenderContainers(grid);
|
756 | 756 |
|
757 | 757 | //add an element with no dimensions that can be used to set focus and capture keystrokes
|
758 |
| - var focuser = $compile('<div class="ui-grid-focuser" tabindex="-1"></div>')($scope); |
| 758 | + var focuser = $compile('<div class="ui-grid-focuser" tabindex="0"></div>')($scope); |
759 | 759 | $elm.append(focuser);
|
760 | 760 |
|
761 | 761 | uiGridCtrl.focus = function () {
|
762 | 762 | focuser[0].focus();
|
| 763 | + //allow for first time grid focus |
| 764 | + focuser.on('focus', function (evt) { |
| 765 | + evt.uiGridTargetRenderContainerId = containerId; |
| 766 | + var rowCol = uiGridCtrl.grid.api.cellNav.getFocusedCell(); |
| 767 | + if (rowCol === null) { |
| 768 | + rowCol = uiGridCtrl.grid.renderContainers[containerId].cellNav.getNextRowCol(uiGridCellNavConstants.direction.DOWN, null, null); |
| 769 | + if (rowCol.row && rowCol.col) { |
| 770 | + uiGridCtrl.cellNav.broadcastCellNav(rowCol); |
| 771 | + } |
| 772 | + } |
| 773 | + }); |
763 | 774 | };
|
764 | 775 |
|
| 776 | + |
| 777 | + |
765 | 778 | // Bind to keydown events in the render container
|
766 | 779 | focuser.on('keydown', function (evt) {
|
767 | 780 | evt.uiGridTargetRenderContainerId = containerId;
|
|
0 commit comments