adobe-photoshop / spaces-design

Adobe Photoshop Design Space
http://adobe-photoshop.github.io/
Other
853 stars 74 forks source link

LayerPanel: fix broken layer face drag-and-drop #3621

Closed shaoshing closed 8 years ago

shaoshing commented 8 years ago

This PR fixes the drag-and-drop in the LayerPanel by changing the type of drag target in the Draggable component from Layer model to layer id, so that the Draggable won't hold a stale layer model.

More details about the fix:

In the recent layer panel PR, LayerFace stores some Layer model attributes (selected/expanded/visible) in its state. When it receive a new layer prop, it will skip rendering if the change is the same as its state. As a result, the Draggable instance will hold the old version because the component is not re-rendered. This makes it fail when Draggable component needs to check whether it is the drag target when a drag event starts, which will always return false. The solution is to switch to layer id, which is a number and will never stale.

baaygun commented 8 years ago

One nit, and one JSDoc nit, but looks great!

shaoshing commented 8 years ago

@volfied Thanks for reviewing. Fixed the JSDoc and addressed the Layer#byIDs function. Back to you.