fix: Auto scroll sidebar to selected page

This commit is contained in:
shariquerik 2021-07-08 20:56:58 +05:30
parent 8475c6c426
commit e8e7211d62
2 changed files with 10 additions and 4 deletions

View file

@ -206,12 +206,12 @@ def save_page(title, parent, public, sb_items, deleted_pages, new_widgets, block
doc.content = blocks
doc.save(ignore_permissions=True)
if json.loads(sb_items):
sort_pages(json.loads(sb_items))
if json.loads(new_widgets):
save_new_widget(doc, title, blocks, new_widgets)
if json.loads(sb_items):
sort_pages(json.loads(sb_items))
if json.loads(deleted_pages):
return delete_pages(json.loads(deleted_pages))

View file

@ -145,6 +145,8 @@ frappe.views.Workspace = class Workspace {
}
this.build_sidebar_section(category, root_pages);
});
this.sidebar.find('.selected')[0].scrollIntoView();
}
build_sidebar_section(title, root_pages) {
@ -152,7 +154,7 @@ frappe.views.Workspace = class Workspace {
let $title = $(`<div class="standard-sidebar-label">
<span>${frappe.utils.icon("small-down", "xs")}</span>
<span>${__(title)}<span>
<span class="section-title">${__(title)}<span>
</div>`).appendTo(sidebar_section);
this.prepare_sidebar(root_pages, sidebar_section, this.sidebar);
@ -162,6 +164,10 @@ frappe.views.Workspace = class Workspace {
$(e.target).parent().find('.sidebar-item-container').toggleClass('hidden');
});
if (!this.current_page.name) {
$title.trigger("click");
}
if (Object.keys(root_pages).length === 0) {
sidebar_section.addClass('hidden');
}