|
879 | 879 | evt.stopPropagation();
|
880 | 880 | $scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT);
|
881 | 881 | break;
|
882 |
| - case uiGridConstants.keymap.ENTER: // Enter (Leave Field) |
883 |
| - $scope.stopEdit(evt); |
884 |
| - break; |
885 |
| - case uiGridConstants.keymap.TAB: |
886 |
| - $scope.stopEdit(evt); |
887 |
| - break; |
888 | 882 | }
|
889 | 883 |
|
890 | 884 | if ($scope.deepEdit) {
|
891 | 885 | switch (evt.keyCode) {
|
892 | 886 | case uiGridConstants.keymap.LEFT:
|
893 |
| - evt.stopPropagation(); |
894 |
| - break; |
895 | 887 | case uiGridConstants.keymap.RIGHT:
|
896 |
| - evt.stopPropagation(); |
897 |
| - break; |
898 | 888 | case uiGridConstants.keymap.UP:
|
899 |
| - evt.stopPropagation(); |
900 |
| - break; |
901 | 889 | case uiGridConstants.keymap.DOWN:
|
902 | 890 | evt.stopPropagation();
|
903 | 891 | break;
|
|
910 | 898 | $scope.stopEdit(evt);
|
911 | 899 | }
|
912 | 900 | }
|
| 901 | + else { |
| 902 | + //handle enter and tab for editing not using cellNav |
| 903 | + switch (evt.keyCode) { |
| 904 | + case uiGridConstants.keymap.ENTER: // Enter (Leave Field) |
| 905 | + case uiGridConstants.keymap.TAB: |
| 906 | + evt.stopPropagation(); |
| 907 | + evt.preventDefault(); |
| 908 | + $scope.stopEdit(evt); |
| 909 | + break; |
| 910 | + } |
| 911 | + } |
913 | 912 |
|
914 | 913 | return true;
|
915 | 914 | });
|
|
1000 | 999 | ['uiGridConstants', 'uiGridEditConstants',
|
1001 | 1000 | function (uiGridConstants, uiGridEditConstants) {
|
1002 | 1001 | return {
|
| 1002 | + require: ['?^uiGrid', '?^uiGridRenderContainer'], |
1003 | 1003 | scope: true,
|
1004 | 1004 | compile: function () {
|
1005 | 1005 | return {
|
1006 | 1006 | pre: function ($scope, $elm, $attrs) {
|
1007 | 1007 |
|
1008 | 1008 | },
|
1009 |
| - post: function ($scope, $elm, $attrs) { |
| 1009 | + post: function ($scope, $elm, $attrs, controllers) { |
| 1010 | + var uiGridCtrl = controllers[0]; |
| 1011 | + var renderContainerCtrl = controllers[1]; |
1010 | 1012 |
|
1011 | 1013 | //set focus at start of edit
|
1012 | 1014 | $scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function () {
|
|
1030 | 1032 | evt.stopPropagation();
|
1031 | 1033 | $scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT);
|
1032 | 1034 | break;
|
1033 |
| - case uiGridConstants.keymap.ENTER: // Enter (Leave Field) |
1034 |
| - $scope.stopEdit(evt); |
1035 |
| - break; |
1036 |
| - case uiGridConstants.keymap.LEFT: |
1037 |
| - $scope.stopEdit(evt); |
1038 |
| - break; |
1039 |
| - case uiGridConstants.keymap.RIGHT: |
1040 |
| - $scope.stopEdit(evt); |
1041 |
| - break; |
1042 |
| - case uiGridConstants.keymap.UP: |
1043 |
| - evt.stopPropagation(); |
1044 |
| - break; |
1045 |
| - case uiGridConstants.keymap.DOWN: |
1046 |
| - evt.stopPropagation(); |
1047 |
| - break; |
1048 |
| - case uiGridConstants.keymap.TAB: |
| 1035 | + } |
| 1036 | + if (uiGridCtrl && uiGridCtrl.grid.api.cellNav) { |
| 1037 | + evt.uiGridTargetRenderContainerId = renderContainerCtrl.containerId; |
| 1038 | + if (uiGridCtrl.cellNav.handleKeyDown(evt) !== null) { |
1049 | 1039 | $scope.stopEdit(evt);
|
1050 |
| - break; |
| 1040 | + } |
| 1041 | + } |
| 1042 | + else { |
| 1043 | + //handle enter and tab for editing not using cellNav |
| 1044 | + switch (evt.keyCode) { |
| 1045 | + case uiGridConstants.keymap.ENTER: // Enter (Leave Field) |
| 1046 | + case uiGridConstants.keymap.TAB: |
| 1047 | + evt.stopPropagation(); |
| 1048 | + evt.preventDefault(); |
| 1049 | + $scope.stopEdit(evt); |
| 1050 | + break; |
| 1051 | + } |
1051 | 1052 | }
|
1052 | 1053 | return true;
|
1053 | 1054 | });
|
|
0 commit comments