Skip to main content

Search and Top Navigation

#15103 new bug ()

Opened November 21, 2016 11:00PM UTC

Last modified November 21, 2016 11:00PM UTC

Make an element draggable can lead to unfocusable elements being focused on click (mouseup) in IE11

Reported by: JoolsCaesar Owned by:
Priority: minor Milestone: none
Component: ui.draggable Version: 1.12.1
Keywords: Cc:
Blocked by: Blocking:

When child elements of focusable elements have certain CSS properties, those child elements become focusable in IE11. This is a bug with IE11 that Microsoft have no intention of fixing.

The problem often isn't noticeable unless you have css focus highlighting as described in the bug.

jQuery UI's draggable has a piece of code where it focuses draggable elements on mouse up:

_mouseUp: function( event ) {
   // Only need to focus if the event occurred on the draggable itself, see #10527
   if ( ) ) {
      // The interaction is over; whether or not the click resulted in a drag,
      // focus the element

In most browsers this has the desired effect, focusing the closest focusable element, otherwise having no effect. However in IE11 it is not unusual for this to lead to the focusing of an element that should not be focusable. While the focusabilty is not jquery UI's fault, the end result is worse than if the item was not draggable, because a programatic focus is treated by IE11 as though it was a tab-focus and triggers auto scrolling.

See this jsfiddle as an example:

Scroll the div until you can see the text "Inner bottom".

Click the text and it will auto scroll the content back to the top.

This does not occur if you comment out the line making it draggable.

See this abstract of the relevant code which merely calls focus() on mouseup:

Follow the same steps as above and observe the same pattern.

The workaround I'm currently using is to change the line of code that does the focussing, to first check that the element it's focusing should be focusable:

Attachments (0)
Change History (0)