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 25089 5bce36f9c047
parent 25088 917e6c1d5d08
child 25090 e6566a390dba
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 18:36:05 2014 +0200
+++ 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
@@ -2956,7 +2956,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);