|
19 | 19 | direction: {LEFT: 0, RIGHT: 1, UP: 2, DOWN: 3, PG_UP: 4, PG_DOWN: 5},
|
20 | 20 | EVENT_TYPE: {
|
21 | 21 | KEYDOWN: 0,
|
22 |
| - CLICK: 1 |
| 22 | + CLICK: 1, |
| 23 | + CLEAR: 2 |
23 | 24 | }
|
24 | 25 | });
|
25 | 26 |
|
|
108 | 109 |
|
109 | 110 | //get column to left
|
110 | 111 | if (nextColIndex > curColIndex) {
|
| 112 | + // On the first row |
| 113 | + // if (curRowIndex === 0 && curColIndex === 0) { |
| 114 | + // return null; |
| 115 | + // } |
111 | 116 | if (curRowIndex === 0) {
|
112 | 117 | return new RowCol(curRow, focusableCols[nextColIndex]); //return same row
|
113 | 118 | }
|
|
800 | 805 | </file>
|
801 | 806 | </example>
|
802 | 807 | */
|
803 |
| - module.directive('uiGridCellnav', ['gridUtil', 'uiGridCellNavService', 'uiGridCellNavConstants', |
804 |
| - function (gridUtil, uiGridCellNavService, uiGridCellNavConstants) { |
| 808 | + module.directive('uiGridCellnav', ['gridUtil', 'uiGridCellNavService', 'uiGridCellNavConstants', 'uiGridConstants', |
| 809 | + function (gridUtil, uiGridCellNavService, uiGridCellNavConstants, uiGridConstants) { |
805 | 810 | return {
|
806 | 811 | replace: true,
|
807 | 812 | priority: -150,
|
|
829 | 834 | _scope.$broadcast(uiGridCellNavConstants.CELL_NAV_EVENT, newRowCol, modifierDown);
|
830 | 835 | };
|
831 | 836 |
|
| 837 | + uiGridCtrl.cellNav.clearFocus = grid.cellNav.clearFocus = function () { |
| 838 | + _scope.$broadcast(uiGridCellNavConstants.CELL_NAV_EVENT, { eventType: uiGridCellNavConstants.EVENT_TYPE.CLEAR }); |
| 839 | + }; |
| 840 | + |
832 | 841 | uiGridCtrl.cellNav.broadcastFocus = function (rowCol, modifierDown) {
|
833 | 842 | modifierDown = !(modifierDown === undefined || !modifierDown);
|
834 | 843 |
|
|
870 | 879 | // Figure out which new row+combo we're navigating to
|
871 | 880 | var rowCol = uiGridCtrl.grid.renderContainers[containerId].cellNav.getNextRowCol(direction, lastRowCol.row, lastRowCol.col);
|
872 | 881 |
|
| 882 | + // Shift+tab on top-left cell should exit cellnav on render container |
| 883 | + if ( |
| 884 | + // Navigating left |
| 885 | + direction === uiGridCellNavConstants.direction.LEFT && |
| 886 | + // Trying to stay on same row |
| 887 | + rowCol.row === lastRowCol.row && |
| 888 | + evt.keyCode === uiGridConstants.keymap.TAB && |
| 889 | + evt.shiftKey |
| 890 | + ) { |
| 891 | + uiGridCtrl.cellNav.clearFocus(); |
| 892 | + return true; |
| 893 | + } |
| 894 | + // Tab on bottom-right cell should exit cellnav on render container |
| 895 | + else if ( |
| 896 | + direction === uiGridCellNavConstants.direction.RIGHT && |
| 897 | + rowCol.row === lastRowCol.row && |
| 898 | + evt.keyCode === uiGridConstants.keymap.TAB && |
| 899 | + !evt.shiftKey |
| 900 | + ) { |
| 901 | + uiGridCtrl.cellNav.clearFocus(); |
| 902 | + return true; |
| 903 | + } |
| 904 | + |
| 905 | + |
873 | 906 | rowCol.eventType = uiGridCellNavConstants.EVENT_TYPE.KEYDOWN;
|
874 | 907 |
|
875 | 908 | // Broadcast the navigation
|
|
1045 | 1078 | evt.stopPropagation();
|
1046 | 1079 | });
|
1047 | 1080 |
|
| 1081 | + $elm.find('div').on('focus', function (evt) { |
| 1082 | + console.log('cellNav focus'); |
| 1083 | + uiGridCtrl.cellNav.broadcastCellNav(new RowCol($scope.row, $scope.col), evt.ctrlKey || evt.metaKey); |
| 1084 | + }); |
| 1085 | + |
1048 | 1086 | // This event is fired for all cells. If the cell matches, then focus is set
|
1049 | 1087 | $scope.$on(uiGridCellNavConstants.CELL_NAV_EVENT, function (evt, rowCol, modifierDown) {
|
| 1088 | + if (evt.eventType === uiGridCellNavConstants.EVENT_TYPE.CLEAR) { |
| 1089 | + clearFocus(); |
| 1090 | + return; |
| 1091 | + } |
| 1092 | + |
1050 | 1093 | if (rowCol.row === $scope.row &&
|
1051 | 1094 | rowCol.col === $scope.col) {
|
1052 | 1095 | if (uiGridCtrl.grid.options.modifierKeysToMultiSelectCells && modifierDown &&
|
|
1058 | 1101 |
|
1059 | 1102 | // This cellNav event came from a keydown event so we can safely refocus
|
1060 | 1103 | if (rowCol.hasOwnProperty('eventType') && rowCol.eventType === uiGridCellNavConstants.EVENT_TYPE.KEYDOWN) {
|
| 1104 | + console.log('focus from navEvent'); |
1061 | 1105 | $elm.find('div')[0].focus();
|
1062 | 1106 | }
|
1063 | 1107 | }
|
|
1067 | 1111 | });
|
1068 | 1112 |
|
1069 | 1113 | function setTabEnabled() {
|
1070 |
| - $elm.find('div').attr("tabindex", -1); |
| 1114 | + $elm.find('div').attr("tabindex", 0); |
1071 | 1115 | }
|
1072 | 1116 |
|
1073 | 1117 | function setFocused() {
|
|
0 commit comments