Fixes issue 27957: Grid button don't get stuck after autosaving new record
authorAugusto Mauch <augusto.mauch@openbravo.com>
Fri, 24 Oct 2014 09:38:26 +0200
changeset 25359 2e8b032171e0
parent 25148 6af26661c789
child 25360 379709296e4d
Fixes issue 27957: Grid button don't get stuck after autosaving new record

In the fix [1] of this issue [2], a change was made to force reselecting a new record even if it was already selected, because otherwise when a record was created in grid mode while a filter was applied, when the record was saved the selection was lost.

The problem is that that change should only be applied when the editCompletionEvent is 'programmatic'. In the other cases (i.e. 'tab', 'enter', etc), the focus goes to another record, so it did not apply to [2]. In fact when the editCompletion event is not 'programmatic' not only reselecting the record was not needed, but also it caused the grid buttons to get stuck.

[1] https://code.openbravo.com/erp/devel/pi/rev/dfda65fa925f89a21eee64f35d7aadb252c90dab
[2] https://issues.openbravo.com/view.php?id=26702
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Thu Oct 23 17:31:32 2014 +0000
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js	Fri Oct 24 09:38:26 2014 +0200
@@ -2897,7 +2897,9 @@
     this.view.standardWindow.autoSaveDone(this.view, true);
 
     // if nothing else got selected, select ourselves then
-    if (!this.getSelectedRecord() || (this.getSelectedRecord().id === record._originalId)) {
+    // if there is already a record selected, only force reselecting that record if the editCompletionEvent was 'programmatic', 
+    // otherwise ('enter', 'tab', etc) it is not needed, and doing it causes https://issues.openbravo.com/view.php?id=27957  
+    if (!this.getSelectedRecord() || (editCompletionEvent === 'programmatic' && this.getSelectedRecord().id === record._originalId)) {
       this.selectRecord(record);
       keepSelection = true;
       this.view.refreshChildViews(keepSelection);