Open Bug 260850 Opened 20 years ago Updated 2 years ago

onChange event in select list is firing before onChange event in text box

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

defect

Tracking

()

People

(Reporter: mephraim, Unassigned)

References

()

Details

Attachments

(2 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.3) Gecko/20040910
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.3) Gecko/20040910

When a change is made in a text box with an onChange that updates the selected
item in a select list, and an item in the select list (also with an onChange
event to update the selected item) is selected, the onChange event in the select
list is fired before the onChange in the text box.  An example can be found at
http://www.leepfrog.com/~mephraim/mozbug/.  If you select an item in the select
list, the text boxes are populated.  If you change some text in either text box
then select another item in the select list, the select list updates the wrong
item.  The text onChange updates the currently selected list item and should
updated the currently selected item in the list, but uses the new selected
index.  This can be consistently reproduced.

Reproducible: Always
Steps to Reproduce:
1.Select "Link 1" in select list
2.Update "Link 1" text in Name text box to say "Link 10"
3.Click on "Link 2" in the select List

Actual Results:  
"Link 2" in the select list is updated to say "Link 10"

Expected Results:  
"Link 1" in the select list should be updated to say "Link 10"
Please attach the testcase to the bug (using
https://bugzilla.mozilla.org/attachment.cgi?bugid=260850&action=enter) so it
won't get lost.

Chances are, the issue is that the <select>'s onchange fires onfocus and the
other fires onblur.  Which is fine (and expected by web pages), but the focus
happens before the blur (which is also what web pages expect).

> Expected Results:  
> "Link 1" in the select list should be updated to say "Link 10"

To be frank, I don't see why this is expected given common expectations of how
focus/blur interact with onchange....
I created a test page (http://www.leepfrog.com/~mephraim/mozbug/index2.html)
that displays select focus events and text blur events as they happen.  This
proves that the Text box blur is happening before the select focus. 

If you go to http://www.leepfrog.com/~mephraim/mozbug/index2.html and select and
item in the select list, it should display the focus event below.  Now if you
select the text box, then select an item in the select list, you can see the the
blur event on the text box is fired before the focus event on the select list.

I appreciate your comments, Boris, but I don't think that is what is happening. 
Indeed.  :)

Mats, any idea what's up here?
Assignee: general → events
Status: UNCONFIRMED → NEW
Component: Browser-General → Event Handling
Ever confirmed: true
OS: Windows 2000 → All
QA Contact: general → ian
Hardware: PC → All
Attached file Testcase
Can confirm this bug with 
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b4) Gecko/20050830
Firefox/1.0+
Depends on: 306437
Assignee: events → nobody
QA Contact: ian → events
Component: Event Handling → User events and focus handling
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: