Skip to content

Commit 4021e1d

Browse files
committed
Panel.js: fix applet order numbers after applet DND
1 parent 1201332 commit 4021e1d

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

js/ui/panel.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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,19 +1968,18 @@ PanelZoneDNDHandler.prototype = {
19681968
}
19691969
}
19701970

1971-
let children = this._panelZone.get_children();
19721971
let curAppletPos = 0;
19731972
let insertAppletPos = 0;
19741973

1975-
for (let i = 0, len = children.length; i < len; i++) {
1976-
if (children[i]._delegate instanceof Applet.Applet){
1977-
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;
19781977
curAppletPos++;
1979-
} else if (children[i] == this._dragPlaceholder.actor){
1978+
} else if (child == this._dragPlaceholder.actor){
19801979
insertAppletPos = curAppletPos;
19811980
curAppletPos++;
19821981
}
1983-
}
1982+
});
19841983

19851984
source.actor._applet._newOrder = insertAppletPos;
19861985
source.actor._applet._newPanelLocation = this._panelZone;
@@ -2002,9 +2001,7 @@ PanelZoneDNDHandler.prototype = {
20022001
}
20032002

20042003
if (sourcebox.has_style_class_name("panelRight") || sourcebox.has_style_class_name("panelLeft")) {
2005-
children = sourcebox.get_children();
2006-
2007-
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 */
20082005
if (sourcebox.get_parent()._delegate.is_vertical) {
20092006
let height = sourcebox.get_height();
20102007
if (height < EDIT_MODE_MIN_BOX_SIZE * global.ui_scale)

0 commit comments

Comments
 (0)