Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#10212 closed bug (fixed)

Draggable: ui-draggable-handle class is added to all matching elements on the page

Reported by: mizzao Owned by: tj.vantoll
Priority: minor Milestone: 1.11.1
Component: ui.draggable Version: 1.11.0
Keywords: Cc:
Blocked by: Blocking:

Description

I had a page with a lot of potential draggables and dynamic changes using Meteor, so instead of activating the draggable methods all at once, I created them on mouseenter and destroyed them on mouseleave.

While this adds and removes the ui-draggable class correctly as elements are moused over, the ui-draggable-handle is added to all matching handle elements on the page as soon as any draggable is moused over. The class is still removed on an individual destroy.

To see this, go to this fiddle and mouse over the elements with their classes visible in Chrome's developer tools.

http://jsfiddle.net/4zE3p/ or http://jsfiddle.net/4zE3p/embedded/result/

This appears to occur from https://github.com/jquery/jquery-ui/blob/1.11.0/ui/draggable.js#L318 where if a selector like ".handle" is passed in as an option, $(".handle") is going to select all handles on the page - instead of just one descendant handle. This behavior did not occur in 1.10.4 as there was no ui-draggable-handle class used in that release.

Moreover, setting {addClasses: false} does not disable this behavior because _setHandleClassName does not check the value of addClasses: https://github.com/jquery/jquery-ui/blob/1.11.0/ui/draggable.js#L73

Change History (4)

comment:1 Changed 3 years ago by tj.vantoll

Owner: set to tj.vantoll
Status: newassigned
Summary: ui-draggable-handle class is added to all matching elements on the pageDraggable: ui-draggable-handle class is added to all matching elements on the page

Thanks mizzao. The query to find handles should search within the element and not globally. I can patch this.

comment:3 Changed 3 years ago by TJ VanToll

Resolution: fixed
Status: assignedclosed

Draggable: Only apply ui-draggable-handle within the draggable instance

Fixes #10212 Closes gh-1284

Changeset: 7594a3142547e078326872cb0d6e2d7f32f4c808

comment:4 Changed 3 years ago by tj.vantoll

Milestone: none1.11.1
Note: See TracTickets for help on using tickets.