@@ -1957,7 +1957,7 @@ PanelZoneDNDHandler.prototype = {
19571957 acceptDrop : function ( source , actor , x , y , time ) {
19581958 this . _origAppletCenters = null ;
19591959
1960- if ( ! ( source instanceof Applet . Applet ) ) return false ;
1960+ if ( ! ( source instanceof Applet . Applet ) || ! this . _dragPlaceholder ) return false ;
19611961
19621962 // We want to ensure that applets placed in a panel can be shown correctly
19631963 // If the applet is of type Icon Applet then should be fine
@@ -1968,31 +1968,20 @@ PanelZoneDNDHandler.prototype = {
19681968 }
19691969 }
19701970
1971- let children = this . _panelZone . get_children ( ) ;
19721971 let curAppletPos = 0 ;
1973- let insertAppletPos = - 1 ;
1974-
1975- const {
1976- panel : { panelId : sourceAppletPanel } ,
1977- locationLabel : sourceAppletLocation ,
1978- } = source . actor . _applet ;
1972+ let insertAppletPos = 0 ;
19791973
1980- for ( let i = 0 , len = children . length ; i < len ; i ++ ) {
1981- if ( children [ i ] . _delegate instanceof Applet . Applet ) {
1982- children [ i ] . _applet . _newOrder = curAppletPos ;
1974+ this . _panelZone . get_children ( ) . forEach ( child => {
1975+ if ( child . _delegate instanceof Applet . Applet && child . _delegate !== source . actor . _applet ) {
1976+ child . _applet . _newOrder = curAppletPos ;
19831977 curAppletPos ++ ;
1984- } else if ( children [ i ] == this . _dragPlaceholder . actor ) {
1978+ } else if ( child == this . _dragPlaceholder . actor ) {
19851979 insertAppletPos = curAppletPos ;
19861980 curAppletPos ++ ;
19871981 }
1988- }
1982+ } ) ;
19891983
1990- const isSameLocation = (
1991- sourceAppletPanel === this . _panelId
1992- && sourceAppletLocation === this . _zoneString
1993- && insertAppletPos === - 1
1994- ) ;
1995- if ( ! isSameLocation ) source . actor . _applet . _newOrder = insertAppletPos === - 1 ? 0 : insertAppletPos ;
1984+ source . actor . _applet . _newOrder = insertAppletPos ;
19961985 source . actor . _applet . _newPanelLocation = this . _panelZone ;
19971986 source . actor . _applet . _zoneString = this . _zoneString ;
19981987 source . actor . _applet . _newPanelId = this . _panelId ;
@@ -2012,9 +2001,7 @@ PanelZoneDNDHandler.prototype = {
20122001 }
20132002
20142003 if ( sourcebox . has_style_class_name ( "panelRight" ) || sourcebox . has_style_class_name ( "panelLeft" ) ) {
2015- children = sourcebox . get_children ( ) ;
2016-
2017- if ( children . length == 0 ) { /* put back some minimum space if the source box is now empty */
2004+ if ( sourcebox . get_children ( ) . length == 0 ) { /* put back some minimum space if the source box is now empty */
20182005 if ( sourcebox . get_parent ( ) . _delegate . is_vertical ) {
20192006 let height = sourcebox . get_height ( ) ;
20202007 if ( height < EDIT_MODE_MIN_BOX_SIZE * global . ui_scale )
0 commit comments