Skip to content

Commit

Permalink
fix(edit): #3742 dropdown was not calling out to cellNav for cellNav …
Browse files Browse the repository at this point in the history
…keys.

also refactored the generic editor keydown event code
  • Loading branch information
swalters committed Jun 11, 2015
1 parent 13ab094 commit 2edc4d6
Showing 1 changed file with 31 additions and 30 deletions.
61 changes: 31 additions & 30 deletions src/features/edit/js/gridEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -879,25 +879,13 @@
evt.stopPropagation();
$scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT);
break;
case uiGridConstants.keymap.ENTER: // Enter (Leave Field)
$scope.stopEdit(evt);
break;
case uiGridConstants.keymap.TAB:
$scope.stopEdit(evt);
break;
}

if ($scope.deepEdit) {
switch (evt.keyCode) {
case uiGridConstants.keymap.LEFT:
evt.stopPropagation();
break;
case uiGridConstants.keymap.RIGHT:
evt.stopPropagation();
break;
case uiGridConstants.keymap.UP:
evt.stopPropagation();
break;
case uiGridConstants.keymap.DOWN:
evt.stopPropagation();
break;
Expand All @@ -910,6 +898,17 @@
$scope.stopEdit(evt);
}
}
else {
//handle enter and tab for editing not using cellNav
switch (evt.keyCode) {
case uiGridConstants.keymap.ENTER: // Enter (Leave Field)
case uiGridConstants.keymap.TAB:
evt.stopPropagation();
evt.preventDefault();
$scope.stopEdit(evt);
break;
}
}

return true;
});
Expand Down Expand Up @@ -1000,13 +999,16 @@
['uiGridConstants', 'uiGridEditConstants',
function (uiGridConstants, uiGridEditConstants) {
return {
require: ['?^uiGrid', '?^uiGridRenderContainer'],
scope: true,
compile: function () {
return {
pre: function ($scope, $elm, $attrs) {

},
post: function ($scope, $elm, $attrs) {
post: function ($scope, $elm, $attrs, controllers) {
var uiGridCtrl = controllers[0];
var renderContainerCtrl = controllers[1];

//set focus at start of edit
$scope.$on(uiGridEditConstants.events.BEGIN_CELL_EDIT, function () {
Expand All @@ -1030,24 +1032,23 @@
evt.stopPropagation();
$scope.$emit(uiGridEditConstants.events.CANCEL_CELL_EDIT);
break;
case uiGridConstants.keymap.ENTER: // Enter (Leave Field)
$scope.stopEdit(evt);
break;
case uiGridConstants.keymap.LEFT:
$scope.stopEdit(evt);
break;
case uiGridConstants.keymap.RIGHT:
$scope.stopEdit(evt);
break;
case uiGridConstants.keymap.UP:
evt.stopPropagation();
break;
case uiGridConstants.keymap.DOWN:
evt.stopPropagation();
break;
case uiGridConstants.keymap.TAB:
}
if (uiGridCtrl && uiGridCtrl.grid.api.cellNav) {
evt.uiGridTargetRenderContainerId = renderContainerCtrl.containerId;
if (uiGridCtrl.cellNav.handleKeyDown(evt) !== null) {
$scope.stopEdit(evt);
break;
}
}
else {
//handle enter and tab for editing not using cellNav
switch (evt.keyCode) {
case uiGridConstants.keymap.ENTER: // Enter (Leave Field)
case uiGridConstants.keymap.TAB:
evt.stopPropagation();
evt.preventDefault();
$scope.stopEdit(evt);
break;
}
}
return true;
});
Expand Down

0 comments on commit 2edc4d6

Please sign in to comment.