From 8f8ffe76e6d8eb82bf522835653010e8167bac7c Mon Sep 17 00:00:00 2001 From: mindless Date: Tue, 23 Mar 2010 16:17:12 +0000 Subject: [PATCH] [FIXED HUDSON-6025] simplify form.onsubmit handling with combobox. 1) in onblur handler, simply restore old form.onsubmit rather than adding another wrapper to call the old handler (which can result in a deep call stack if several comboboxes are used prior to form submission). 2) in onsubmit handler when focused, only call the original onsubmit when the dropdown is not showing (ie don't call it when we intercept the submit to just select an item from the list and return false) I didn't figure out exactly why, but the current code could result in the original form.onsubmit handler not being called on form submission when multiple comboboxes are used. This simplification seems to resolve the issue. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@29149 71c3de6d-444a-0410-be80-ed276b4c234a --- war/resources/scripts/combobox.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/war/resources/scripts/combobox.js b/war/resources/scripts/combobox.js index 0ff4e7d519..7b8ddb7d91 100644 --- a/war/resources/scripts/combobox.js +++ b/war/resources/scripts/combobox.js @@ -114,17 +114,15 @@ function ComboBox(idOrField, callback, config) { this.field.form.oldonsubmit = this.field.form.onsubmit; this.field.onfocus = function() { this.form.onsubmit = function() { + if (self.isDropdownShowing) return false; if (this.oldonsubmit) this.oldonsubmit(); - return ! self.isDropdownShowing; + return true; }; } this.field.onblur = function() { var cb = this.comboBox; this.hideTimeout = setTimeout(function() { cb.hideDropdown(); }, 100); - this.form.onsubmit = function() { - if (this.oldonsubmit) this.oldonsubmit(); - return true; - }; + this.form.onsubmit = this.form.oldonsubmit; } // privileged methods -- GitLab