From 2edc4d66193b37734733b2a8a1999921426424b2 Mon Sep 17 00:00:00 2001 From: swalters Date: Thu, 11 Jun 2015 14:43:39 -0500 Subject: [PATCH] fix(edit): #3742 dropdown was not calling out to cellNav for cellNav keys. also refactored the generic editor keydown event code --- src/features/edit/js/gridEdit.js | 61 ++++++++++++++++---------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/src/features/edit/js/gridEdit.js b/src/features/edit/js/gridEdit.js index ed07163a5f..5a7a79e298 100644 --- a/src/features/edit/js/gridEdit.js +++ b/src/features/edit/js/gridEdit.js @@ -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; @@ -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; }); @@ -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 () { @@ -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; });