Bug Tracker

Opened 11 years ago

Closed 11 years ago

#12161 closed bug (cantfix)

.focus doesn't work when performed within blur callback

Reported by: [email protected] Owned by:
Priority: low Milestone: None
Component: event Version: git
Keywords: Cc:
Blocked by: Blocking:

Description

When blurring from a text field I should be able to refocus on the field (for example, when an error is detected) from within the blur callback. This seems to work inconsistently between browsers. In IE8 it works. In Chrome is stays highlighted but really isn't. In Firefox 14 it does not stay highlighted.

Replication:

  1. Click inside of the input box.
  2. Click outside of the checkbox.

Expected Results: The input box focused after clicking outside of the textbox.

Actual Results: The textbox is not focused.

Code to test with: http://jsfiddle.net/6JBsz/6/

Change History (2)

comment:1 Changed 11 years ago by scottgonzalez

You should really set focus asynchronously, especially if you're not preventing the default action of some other event that is causing focus to shift.

comment:2 Changed 11 years ago by timmywil

Component: unfiledevent
Priority: undecidedlow
Resolution: cantfix
Status: newclosed

Scott is right. Use setTimeout to add the focus call to the end of the stack. blur is called at different times by different browsers.

http://jsfiddle.net/6JBsz/7/

Note: See TracTickets for help on using tickets.