Fixes issue 17954: In IE 9, focus is not in place when creating a new record in grid
authorMartin Taal <martin.taal@openbravo.com>
Fri, 22 Jul 2011 07:20:05 +0200
changeset 13245 7dc5b024cf94
parent 13244 b5840ad5e283
child 13246 b67d11a30224
Fixes issue 17954: In IE 9, focus is not in place when creating a new record in grid
Changed handling of focus to work with a small delay for ie, added correct handling of selecting values when getting focus
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-date.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-date.js	Thu Jul 21 20:38:38 2011 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-date.js	Fri Jul 22 07:20:05 2011 +0200
@@ -189,6 +189,10 @@
     }
   },
   
+  doSelectElement: function() {
+    this.Super('doSelectElement', [this.dateTextField]);
+  },
+  
   // update the value in update value as this is called from cellEditEnd in the
   // grid
   updateValue: function() {
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js	Thu Jul 21 20:38:38 2011 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js	Fri Jul 22 07:20:05 2011 +0200
@@ -734,7 +734,13 @@
             delete this.getFields()[i].canFocus;
           }
           if (!this.ignoreFirstFocusEvent && this.view.isActiveView()) {
-            this.setFocusInForm();
+            if (isc.Browser.isIE) {
+              // this is really needed for IE, it is also present
+              // in smartclient code when setting the focus
+              this.delayCall('setFocusInForm', [], 100);
+            } else {
+              this.setFocusInForm();
+            }
           }
           delete this.ignoreFirstFocusEvent;
         }
@@ -1265,12 +1271,7 @@
       // in which case the selection is not update, .select()
       // does what we want
       if (!isc.isA.TextAreaItem(nextItem)) {
-        if (nextItem.getElement()) {
-          nextItem.getElement().select();
-        } else {
-          // works for date values
-          nextItem.selectValue();
-        }
+        nextItem.doSelectElement();
       }
     }
   },
--- a/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js	Thu Jul 21 20:38:38 2011 +0200
+++ b/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js	Fri Jul 22 07:20:05 2011 +0200
@@ -140,11 +140,20 @@
     delete this._rememberedWasValueSelected;
   },
   
-  doSelectElement: function() {
-    if (this.getElement()) {
-      this.getElement().select();
+  doSelectElement: function(item) {
+    item = item || this;
+    if (item.getElement() && item.getElement().select) {
+      item.getElement().select();
+    } else {
+      this.Super('selectValue', arguments);
     }
   },
+  
+  _original_focusInItem: isc.FormItem.getPrototype().focusInItem,
+  focusInItem: function() {
+    this._original_focusInItem();
+    this.doRestoreSelection();
+  },
 
   blur: function(form, item){
     if (item._hasChanged && form && form.handleItemChange) {