Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#9420 closed bug (fixed)

Dialog: Close causes blur of window in IE9

Reported by: rcogswell Owned by: rcogswell
Priority: minor Milestone: 1.10.4
Component: ui.dialog Version: 1.10.0
Keywords: Cc:
Blocked by: Blocking:

Description

The significant aspects for reproducing this are as follows: click a link that triggers ...

  1. the removal/replacement of the html for the link
  2. opening a dialog
  3. fade out the contents of the dialog
  4. close the dialog

For IE 9 (and 7 and 8 simulated via IE 9 developer tools) with jquery ui 1.10 and up, the close of the dialog also causes a blur of the window. I've included a jsfiddle of the html to reproduce this, but it only reproduces the behavior as a standalone page -- even the embedded result wrapper is enough to prevent the buggy behavior. I do not see this behavior in Firefox 3.6.22 or Chrome 27. I do not see this behavior in jquery ui 1.9.2 or earlier. It does not seem to matter which version of jquery I use (tried 1.6.3 and 1.10.2). The behavior does NOT occur if I replace the fadeOut with a fadeTo to an opacity of .1. The behavior DOES still occur even if I do a fadeIn after the fadeOut and before the dialog close. The behavior does NOT occur if I click somewhere else on the page after clicking on the link during the fade (before the dialog close). The behavior does NOT occur if the javascript does not remove the link originally clicked to trigger the javascript.

This is caused by the ".blur()" call in the following block of code from the ui-dialog close function:

if ( !this.opener.filter(":focusable").focus().length ) {

Hiding a focused element doesn't trigger blur in WebKit so in case we have nothing to focus on, explicitly blur the active element https://bugs.webkit.org/show_bug.cgi?id=47182 $( this.document[0].activeElement ).blur();

}

I suspect the fadeOut causes (once it reaches the hidden state) the activeElement to change to something that results in the blur acting on the window.

http://jsfiddle.net/nhQkZ/8/embedded/result/

Change History (10)

comment:1 Changed 5 years ago by tj.vantoll

Owner: set to rcogswell
Status: newpending

Hi rcogswell,

Thanks for taking the time to contribute to the jQuery UI project. I'm not seeing the behavior you're describing, but the behavior sounds similar to #8443. What do you mean by "causes blur of window"?

By the way you can view a jsFiddle without any embedding by appending "/show" to the URL. For example http://jsfiddle.net/nhQkZ/8/show.

Thanks.

comment:2 Changed 5 years ago by rcogswell

Status: pendingnew

Thanks for the jsFiddle tip -- I'm a jsFiddle newbie. I am able to reproduce the problem using http://jsfiddle.net/nhQkZ/8/show/. To see the issue the jsFiddle needs to be in its own browser window (no other tabs) and you need some other window open behind it. The other window could be another browser window or a window from a different application. By "causes blur of window", I mean that it behaves the same as if you had called "window.blur()", which if you have some other window behind the browser window causes the other window to receive focus and for the browser window to go behind the other window. The blur happens about one second after clicking the "Show Dialog" link (after the fadeOut finishes) as long as you don't click anything else..

comment:3 Changed 5 years ago by tj.vantoll

Status: newopen
Summary: dialog close causes blur of windowDialog: Close causes blur of window in IE9

Ok I see it now. Before I only had one window open.

comment:4 Changed 5 years ago by tj.vantoll

In this situation document.activeElement is the <body>.

In IE9 and IE10 document.body.blur() causes the browser to switch windows o_O.

comment:5 Changed 5 years ago by Jörn Zaefferer

That sounds similar to what this commit was addressing, in draggable: https://github.com/jquery/jquery-ui/commit/eae2c4b358af3ebfae258abfe77eeace48fcefcb

comment:6 in reply to:  5 Changed 5 years ago by tj.vantoll

Replying to joern.zaefferer:

That sounds similar to what this commit was addressing, in draggable: https://github.com/jquery/jquery-ui/commit/eae2c4b358af3ebfae258abfe77eeace48fcefcb

Yeah, it's the same problem.

comment:7 Changed 5 years ago by TJ VanToll

Resolution: fixed
Status: openclosed

Dialog: Safe activeElement access.

Fixed #9420 - Dialog: Close causes blur of window in IE9 Fixed #8443 - Dialog: "unspecified error" when using ie9 and iframe

Changeset: 2dfe85d3e2269a571e07bd550bbd838ee703b833

comment:8 Changed 5 years ago by tj.vantoll

Milestone: none1.11.0

comment:9 Changed 5 years ago by TJ VanToll

Dialog: Safe activeElement access.

Fixed #9420 - Dialog: Close causes blur of window in IE9 Fixed #8443 - Dialog: "unspecified error" when using ie9 and iframe (cherry picked from commit 2dfe85d3e2269a571e07bd550bbd838ee703b833)

Changeset: 29e8077871902a49f3039633a7fb9ac5c4093aa8

comment:10 Changed 5 years ago by Scott González

Milestone: 1.11.01.10.4
Note: See TracTickets for help on using tickets.