From f824741d07fd253950ecfc45f6393c398f8b1e1d Mon Sep 17 00:00:00 2001 From: abaevbog Date: Fri, 22 Nov 2024 03:41:55 -0800 Subject: [PATCH] itemTree: handle restoring child item from trash in notify (#4796) If a child item is restored from the trash and its parent row exists and is open, collapse the parent row and expand it to re-render child items. Fixes: #4791 --- chrome/content/zotero/itemTree.jsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/chrome/content/zotero/itemTree.jsx b/chrome/content/zotero/itemTree.jsx index 6538b91d61..0bc062f0a4 100644 --- a/chrome/content/zotero/itemTree.jsx +++ b/chrome/content/zotero/itemTree.jsx @@ -705,6 +705,16 @@ var ItemTree = class ItemTree extends LibraryTree { sort = id; } } + // If a trashed child item is restored while its parent's row is expanded, + // collapse and re-open the parent to have that child item row added. + else { + let parentItemRowIndex = this.getRowIndexByID(item.parentItemID); + if (parentItemRowIndex === false) continue; + if (this.isContainerOpen(parentItemRowIndex)) { + this.toggleOpenState(parentItemRowIndex, true); + await this.toggleOpenState(parentItemRowIndex); + } + } } if (sort && ids.length != 1) {