Opened 8 years ago

Last modified 3 years ago

#13143 assigned defect

[patch] dojo.dnd.Moveable publishing before updating

Reported by: PEM Owned by: dylan
Priority: high Milestone: 1.15
Component: DnD Version: 1.6.1
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by Eugene Lazutkin)

in dojo.dnd.Moveable onMoveStart and onMoveStop, addClass and removeClass are called AFTER the publish. The problem is that some widgets like Dialog use those classes to check if the item is moving or not, checking if body has a class dojoMove for example.

In some cases, due to some race conditions, onMoveStop publishes, a subscriber is triggered, call a function which checks dojo.body classes, and find dojoMove, then do not do the expected modifications. Tha happens because the removeClass is done after the publish.

        onMoveStart: function(/* dojo.dnd.Mover */ mover){
                // summary:
                //              called before every move operation
                dojo.publish("/dnd/move/start", [mover]);
                dojo.addClass(dojo.body(), "dojoMove");
                dojo.addClass(this.node, "dojoMoveItem");
        },
        onMoveStop: function(/* dojo.dnd.Mover */ mover){
                // summary:
                //              called after every move operation
                dojo.publish("/dnd/move/stop", [mover]);
                dojo.removeClass(dojo.body(), "dojoMove");
                dojo.removeClass(this.node, "dojoMoveItem");
        },

The solution would be to simply do the css modifications BEFORE publishing, which is also more logical. To solve this, we just need to modify the code like this :

        onMoveStart: function(/* dojo.dnd.Mover */ mover){
                // summary:
                //              called before every move operation
                dojo.addClass(dojo.body(), "dojoMove");
                dojo.addClass(this.node, "dojoMoveItem");
                dojo.publish("/dnd/move/start", [mover]);
        },
        onMoveStop: function(/* dojo.dnd.Mover */ mover){
                // summary:
                //              called after every move operation
                dojo.removeClass(dojo.body(), "dojoMove");
                dojo.removeClass(this.node, "dojoMoveItem");
                dojo.publish("/dnd/move/stop", [mover]);
        },

Change History (3)

comment:1 Changed 7 years ago by Eugene Lazutkin

Description: modified (diff)
Summary: dojo.dnd.Moveable publishing before updating[patch] dojo.dnd.Moveable publishing before updating

comment:2 Changed 4 years ago by dylan

Milestone: tbd1.12
Owner: changed from Eugene Lazutkin to dylan
Status: newassigned

comment:3 Changed 3 years ago by dylan

Milestone: 1.131.15

Ticket planning... move current 1.13 tickets out to 1.15 to make it easier to move tickets into the 1.13 milestone.

Note: See TracTickets for help on using tickets.