Closed Bug 238987 Opened 17 years ago Closed 14 years ago

Focus and blur events bubble from some form input controls

Categories

(Core :: DOM: Events, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: bugzilla, Assigned: smaug)

References

Details

Attachments

(3 files, 1 obsolete file)

When a <select> or input type="reset" receive a focus or blur event, such events
bubble when the specs clearly indicate they should not. MSIE 6 and Opera 7.5 do
not do that.
This bugfile spins off from bug 230356. Bug 190557 refers to the same issue but
for checkbox. Cross-browser testcase coming.
I believe we do this on purpose and I know we have code that relies on these
events bubbling....  in fact, the fact that they don't bubble from text inputs
leads to focus event bugs with <input type="file">
Blocks: 190557
Note that the resolution of this somewhat depends on what we decide to do with
text controls (and that depends on the file input stuff in bug 4033).
Depends on: 4033
Depends on: 234455
focus doesn't work on type="input" when clicking inputfield. It does work when clicking the button. Though, the inputfield bug has 
nothing to do with this bug and it doesn't work in 1.8 either.
Assignee: events → Olli.Pettay
Status: NEW → ASSIGNED
Attached patch proposed patch (obsolete) — Splinter Review
Because of bug 334216, non-bubbling events get handled at target also
when dispatched somewhere in anonymous content, so type="file" works.
Attachment #270566 - Flags: superreview?(bzbarsky)
Attachment #270566 - Flags: review?(bzbarsky)
Attachment #270563 - Attachment description: testcase with type="input" → testcase with type="file"
There is no need to call stopPropagation in editor code, if focus and blur events don't bubble. Listener is added there for bubble phase.
Attachment #270566 - Attachment is obsolete: true
Attachment #270573 - Flags: superreview?(bzbarsky)
Attachment #270573 - Flags: review?(bzbarsky)
Attachment #270566 - Flags: superreview?(bzbarsky)
Attachment #270566 - Flags: review?(bzbarsky)
Comment on attachment 270573 [details] [diff] [review]
Fixes also textfield in the file control

This looks OK, I guess, but I wonder whether it'd make sense to move the bubble-prevention into the nsEvent constructor (basically use the message to index into something which would say whether the event bubbles).  I'd really prefer a single data table somewhere to sprinkling this throught the code...

Followup bug on that perhaps?

r+sr=bzbarsky assuming you've tested accesskeys and such and will also check in tests for this.
Attachment #270573 - Flags: superreview?(bzbarsky)
Attachment #270573 - Flags: superreview+
Attachment #270573 - Flags: review?(bzbarsky)
Attachment #270573 - Flags: review+
(In reply to comment #7)
> but I wonder whether it'd make sense to move the
> bubble-prevention into the nsEvent constructor (basically use the message to
> index into something which would say whether the event bubbles).  

yup, I was thinking that too. I'll post a followup (with a patch for 
focus, blur, error, load, unload, scroll, SVGLoad, SVGUnload).
Everything in nsEvent is inline, I wonder how the change will affect 
codesize. Maybe the constructor should call something non-inline.
You could compile and strip to see how codesize is affected.  ;)

I do think that if it's just an index into a table to set default flags (as opposed to an if cascade or something) it shouldn't be that big.
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Whiteboard: Bug 238987 – Focus and blur events bubble from some form input controls
Depends on: 386743
Depends on: 386820
Flags: in-testsuite+
Blocks: 4033
No longer depends on: 4033
Depends on: 389330
Whiteboard: Bug 238987 – Focus and blur events bubble from some form input controls
You need to log in before you can comment on or make changes to this bug.