]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 455476: clicking "mark as duplicate" should focus the dup_id field - Patch by...
authorlpsolit%gmail.com <>
Thu, 1 Jan 2009 23:34:11 +0000 (23:34 +0000)
committerlpsolit%gmail.com <>
Thu, 1 Jan 2009 23:34:11 +0000 (23:34 +0000)
js/field.js

index 497c9d2c1867434cc3b78b68a16b184a7ce03589..a1b6245a96c56c8ba523936b46dc8dc43ed60c77 100644 (file)
@@ -159,10 +159,20 @@ function hideEditableField( container, input, action, field_id, original_value )
  *
  */
 function showEditableField (e, ContainerInputArray) {
+    var inputs = new Array();
+    var inputArea = YAHOO.util.Dom.get(ContainerInputArray[1]);    
+    if ( ! inputArea ){
+        YAHOO.util.Event.preventDefault(e);
+        return;
+    }
     YAHOO.util.Dom.setStyle(ContainerInputArray[0], 'display', 'none');
-    YAHOO.util.Dom.setStyle(ContainerInputArray[1], 'display', 'inline');
-    var inputs = YAHOO.util.Dom.get(ContainerInputArray[1]).getElementsByTagName('input')
-    if( inputs.length > 0) {
+    YAHOO.util.Dom.setStyle(inputArea, 'display', 'inline');
+    if ( inputArea.tagName.toLowerCase() == "input" ) {
+        inputs.push(inputArea);
+    } else {
+        inputs = inputArea.getElementsByTagName('input');
+    }
+    if ( inputs.length > 0 ) {
         // focus on the first field, this makes it easier to edit
         inputs[0].focus();
         inputs[0].select();
@@ -278,15 +288,19 @@ function showHideStatusItems(e, dupArrayInfo) {
 function showDuplicateItem(e) {
     var resolution = document.getElementById('resolution');
     var bug_status = document.getElementById('bug_status');
+    var dup_id = document.getElementById('dup_id');
     if (resolution) {
         if (resolution.value == 'DUPLICATE' && bz_isValueInArray( close_status_array, bug_status.value) ) {
             // hide resolution show duplicate
             YAHOO.util.Dom.setStyle('duplicate_settings', 'display', 'inline');
             YAHOO.util.Dom.setStyle('dup_id_discoverable', 'display', 'none');
+            dup_id.focus();
+            dup_id.select();
         }
         else {
             YAHOO.util.Dom.setStyle('duplicate_settings', 'display', 'none');
             YAHOO.util.Dom.setStyle('dup_id_discoverable', 'display', 'block');
+            dup_id.blur();
         }
     }
     YAHOO.util.Event.preventDefault(e); //prevents the hyperlink from going to the url in the href.