Skip to content

Commit 2edc4d6

Browse files
committed
fix(edit): #3742 dropdown was not calling out to cellNav for cellNav keys.
also refactored the generic editor keydown event code
1 parent 13ab094 commit 2edc4d6

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

Diff for: src/features/edit/js/gridEdit.js

+31-30
Original file line numberDiff line numberDiff line change
@@ -879,25 +879,13 @@
879879
evt.stopPropagation();
880880
$scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT);
881881
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;
888882
}
889883

890884
if ($scope.deepEdit) {
891885
switch (evt.keyCode) {
892886
case uiGridConstants.keymap.LEFT:
893-
evt.stopPropagation();
894-
break;
895887
case uiGridConstants.keymap.RIGHT:
896-
evt.stopPropagation();
897-
break;
898888
case uiGridConstants.keymap.UP:
899-
evt.stopPropagation();
900-
break;
901889
case uiGridConstants.keymap.DOWN:
902890
evt.stopPropagation();
903891
break;
@@ -910,6 +898,17 @@
910898
$scope.stopEdit(evt);
911899
}
912900
}
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+
}
913912

914913
return true;
915914
});
@@ -1000,13 +999,16 @@
1000999
['uiGridConstants', 'uiGridEditConstants',
10011000
function (uiGridConstants, uiGridEditConstants) {
10021001
return {
1002+
require: ['?^uiGrid', '?^uiGridRenderContainer'],
10031003
scope: true,
10041004
compile: function () {
10051005
return {
10061006
pre: function ($scope, $elm, $attrs) {
10071007

10081008
},
1009-
post: function ($scope, $elm, $attrs) {
1009+
post: function ($scope, $elm, $attrs, controllers) {
1010+
var uiGridCtrl = controllers[0];
1011+
var renderContainerCtrl = controllers[1];
10101012

10111013
//set focus at start of edit
10121014
$scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function () {
@@ -1030,24 +1032,23 @@
10301032
evt.stopPropagation();
10311033
$scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT);
10321034
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) {
10491039
$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+
}
10511052
}
10521053
return true;
10531054
});

0 commit comments

Comments
 (0)