Open Bug 1042402 Opened 6 years ago Updated 6 years ago

No focus or blur events fire when text is dropped into <input>

Categories

(Core :: General, defect)

31 Branch
x86
macOS
defect
Not set
normal

Tracking

()

UNCONFIRMED

People

(Reporter: ralphma1109, Unassigned)

Details

(Keywords: reproducible, testcase)

Attachments

(1 file)

Attached file firefox_bug_test.html
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36

Steps to reproduce:

1. Created input field with an onblur callback. 
2. I dragged text (using the mouse) into the input field and then clicked space outside the input field. 
3. Onblur event was not called. 

I tried this on chrome and safari, both worked. 

Using the testfile: 
Drag the text "Test Text" into the input box. Then click out of the box. An alert would pop up if onBlur was called. This is not the case, showing that the onBlur event is not called at the proper time. 


Actual results:

Onblur event was not called when I clicked space outside the input. 


Expected results:

After dragging the text, onblur should be called if I click out of the input box.
This is interesting. Arguably, the input field is never really focused - the selection remains available, and so the input field isn't and was never focused (there is no corresponding focus event in your testcase).

Why would you expect onblur to be called without focus happening?
Component: Untriaged → General
Product: Firefox → Core
(In reply to :Gijs Kruitbosch (Gone July 26 - August 3) from comment #1)
> This is interesting. Arguably, the input field is never really focused - the
> selection remains available, and so the input field isn't and was never
> focused (there is no corresponding focus event in your testcase).
> 
> Why would you expect onblur to be called without focus happening?

This time with needinfo... :-)
Flags: needinfo?(ralphma1109)
(In reply to :Gijs Kruitbosch (Gone July 26 - August 3) from comment #2)
> (In reply to :Gijs Kruitbosch (Gone July 26 - August 3) from comment #1)
> > This is interesting. Arguably, the input field is never really focused - the
> > selection remains available, and so the input field isn't and was never
> > focused (there is no corresponding focus event in your testcase).
> > 
> > Why would you expect onblur to be called without focus happening?
> 
> This time with needinfo... :-)

I did play around with it more and noticed the field doesn't gain focus. Is there a reason, why input fields in Firefox do not gain focus when text is dragged in? I feel like a lot of developers would use onFocus and onBlur to trigger validation for texts placed in a field. But this would not work for dragged in text.
Flags: needinfo?(ralphma1109)
(In reply to ralphma1109 from comment #3)
> (In reply to :Gijs Kruitbosch (Gone July 26 - August 3) from comment #2)
> > (In reply to :Gijs Kruitbosch (Gone July 26 - August 3) from comment #1)
> > > This is interesting. Arguably, the input field is never really focused - the
> > > selection remains available, and so the input field isn't and was never
> > > focused (there is no corresponding focus event in your testcase).
> > > 
> > > Why would you expect onblur to be called without focus happening?
> > 
> > This time with needinfo... :-)
> 
> I did play around with it more and noticed the field doesn't gain focus. Is
> there a reason, why input fields in Firefox do not gain focus when text is
> dragged in? I feel like a lot of developers would use onFocus and onBlur to
> trigger validation for texts placed in a field. But this would not work for
> dragged in text.

Also wanted to highlight that input fields in both chrome and safari do gain focus.
(In reply to ralphma1109 from comment #3)
> (In reply to :Gijs Kruitbosch (Gone July 26 - August 3) from comment #2)
> > (In reply to :Gijs Kruitbosch (Gone July 26 - August 3) from comment #1)
> > > This is interesting. Arguably, the input field is never really focused - the
> > > selection remains available, and so the input field isn't and was never
> > > focused (there is no corresponding focus event in your testcase).
> > > 
> > > Why would you expect onblur to be called without focus happening?
> > 
> > This time with needinfo... :-)
> 
> I did play around with it more and noticed the field doesn't gain focus. Is
> there a reason, why input fields in Firefox do not gain focus when text is
> dragged in?

I don't know. Olli?
Flags: needinfo?(bugs)
Summary: onBlur event is not called when text is dragged into field and the field loses focus → No focus or blur events fire when text is dropped into <input>
I don't see any reason why dropping should focus the drop target. Scripts could always call
.focus() if needed.
Flags: needinfo?(bugs)
Also, I don't see anything in HTML spec which would hint dropping should focus possibly
focusable target.
Okay, I can understand that this isn't a bug. However, I think it would be beneficial for firefox users and developers if dragging text into a text box triggered some event. Since the focus event is not fired, the change event is not fired either.
I'd assume the input event is fired, no?
(In reply to Boris Zbarsky [:bz] from comment #9)
> I'd assume the input event is fired, no?

yes
Did not know that, thank you guys.
You need to log in before you can comment on or make changes to this bug.