Merge pull request #35080 from sokumon/desktop-fixes

This commit is contained in:
Soham Kulkarni 2025-12-06 15:02:27 +05:30 committed by GitHub
commit 766ccdad1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 4 deletions

View file

@ -285,7 +285,12 @@ class DesktopIconGrid {
prepare() {
this.total_pages = 1;
this.icons_data = this.icons_data.sort((a, b) => a.name.localeCompare(b.name));
this.icons_data = this.icons_data.sort((a, b) => {
if (a.idx === b.idx) {
return a.label.localeCompare(b.label); // sort by label if idx is the same
}
return a.idx - b.idx; // sort by idx
});
this.icons_data_by_page =
this.icons_data || this.split_data(this.icons_data, this.page_size.total());
}
@ -465,7 +470,7 @@ class DesktopIconGrid {
if (evt.to.parentElement == evt.from.parentElement) {
let reordered_icons = me.sortable.toArray();
let filters = {
parent_icon: me.parent_icon?.icon_data.label || null,
parent_icon: me.parent_icon?.icon_data.label || "" || null,
};
me.reorder_icons(reordered_icons, filters);
me.parent_icon?.render_folder_thumbnail();
@ -495,11 +500,12 @@ class DesktopIconGrid {
}
reorder_icons(reordered_icons, filters) {
reordered_icons.forEach((d, idx) => {
let icon = get_desktop_icon_by_label(d, filters);
let icon = get_desktop_icon_by_label(d);
if (icon) {
icon.idx = idx;
}
});
frappe.boot.desktop_icons.sort((a, b) => a.idx - b.idx);
}
add_to_main_screen(title) {
let icon = get_desktop_icon_by_label(title);
@ -509,6 +515,7 @@ class DesktopIconGrid {
class DesktopIcon {
constructor(icon, in_folder) {
this.icon_data = icon;
this.icon_data.label = __(this.icon_data.label);
this.icon_title = this.icon_data.label;
this.icon_subtitle = "";
this.icon_type = this.icon_data.icon_type;

View file

@ -12,7 +12,7 @@ frappe.ui.SidebarHeader = class SidebarHeader {
label: "Workspaces",
icon: "wallpaper",
condition: function () {
return me.sibling_workspaces.length > 0;
return me.sibling_workspaces && me.sibling_workspaces.length > 0;
},
items: this.sibling_workspaces,
},