fixes issue 31377: Combo value not selected after open drop-down with keyboard
authorCarlos Aristu <carlos.aristu@openbravo.com>
Thu, 05 Nov 2015 19:00:37 +0100
changeset 27837 e43fcd8f3d3a
parent 27836 a7b2496ca752
child 27838 b4ce1b7f9243
fixes issue 31377: Combo value not selected after open drop-down with keyboard

Now the behavior of the combos when opening the drop-down with the keyboard is the same as when clicking on the arrow button with the mouse.

To solve this problem the handleKeyPress function is overriden to select the current combo value when ALT + keyboard down shortcut is pressed. Also it is checked that the combo is on a valid state before showing the drop-down.
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-combo.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-combo.js	Thu Nov 05 16:49:15 2015 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-combo.js	Thu Nov 05 19:00:37 2015 +0100
@@ -42,5 +42,25 @@
   showPicker: function () {
     this.selectValue();
     this.Super('showPicker', arguments);
+  },
+
+  // Override handleKeyPress to ensure that we select the text when pressing the keyboard shortcut of the drop-down
+  // See issue #31377
+  handleKeyPress: function () {
+    if (this.keyboardShortcutPressed()) {
+      this.selectValue();
+    }
+    return this.Super('handleKeyPress', arguments);
+  },
+
+  // Checks if the ALT + keyboard down key combination has been pressed on a valid state of the combo box
+  keyboardShortcutPressed: function () {
+    if (this.hasFocus && !this.isReadOnly()) {
+      var keyName = isc.EH.lastEvent.keyName;
+      if (keyName === 'Arrow_Down' && isc.EH.altKeyDown()) {
+        return true;
+      }
+    }
+    return false;
   }
 });
\ No newline at end of file