Skip to content

Commit 91ae013

Browse files
committed
feature(edit): add a trigger event to the beginEdit api and scope event.
This allows you to populate complex editors like ui-select with the keystroke that started the edit
1 parent 6a2b503 commit 91ae013

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/features/edit/js/gridEdit.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@
8888
* </pre>
8989
* @param {object} rowEntity the options.data element that was edited
9090
* @param {object} colDef the column that was edited
91+
* @param {object} triggerEvent the event that triggered the edit. Useful to prevent losing keystrokes on some
92+
* complex editors
9193
*/
92-
beginCellEdit: function (rowEntity, colDef) {
94+
beginCellEdit: function (rowEntity, colDef, triggerEvent) {
9395
},
9496
/**
9597
* @ngdoc event
@@ -568,7 +570,7 @@
568570

569571
function beginEditKeyDown(evt) {
570572
if (uiGridEditService.isStartEditKey(evt)) {
571-
beginEdit();
573+
beginEdit(evt);
572574
}
573575
}
574576

@@ -664,7 +666,7 @@
664666
* </pre>
665667
*
666668
*/
667-
function beginEdit() {
669+
function beginEdit(triggerEvent) {
668670
// If we are already editing, then just skip this so we don't try editing twice...
669671
if (inEdit) {
670672
return;
@@ -760,8 +762,8 @@
760762
deregOnEndCellEdit();
761763
});
762764

763-
$scope.$broadcast(uiGridEditConstants.events.BEGIN_CELL_EDIT);
764-
$scope.grid.api.edit.raise.beginCellEdit($scope.row.entity, $scope.col.colDef);
765+
$scope.$broadcast(uiGridEditConstants.events.BEGIN_CELL_EDIT, triggerEvent);
766+
$scope.grid.api.edit.raise.beginCellEdit($scope.row.entity, $scope.col.colDef, triggerEvent);
765767
}
766768

767769
function endEdit(retainFocus) {

0 commit comments

Comments
 (0)