appDisplay: Adjust folder position

If you try and drop an icon that's in the same page, but before the
drop target, it'll be one position ahead of where it should be -
because we just removed one icon before the target position.

Adjust the final position of the to-be-created folder.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1447
This commit is contained in:
Georges Basile Stavracas Neto 2020-09-24 12:00:03 -03:00 committed by Florian Müllner
parent 8d84e05a2a
commit 1709592811

View File

@ -1314,9 +1314,18 @@ class AppDisplay extends BaseAppView {
// The hovered AppIcon always passes its own id as the first
// one, and this is where we want the folder to be created
const [folderPage, folderPosition] =
let [folderPage, folderPosition] =
this._grid.getItemPosition(this._items.get(apps[0]));
// Adjust the final position
folderPosition -= apps.reduce((counter, appId) => {
const [page, position] =
this._grid.getItemPosition(this._items.get(appId));
if (page === folderPage && position < folderPosition)
counter++;
return counter;
}, 0);
let appItems = apps.map(id => this._items.get(id).app);
let folderName = _findBestFolderName(appItems);
if (!folderName)