From cdf9d7ff3253d247364e8417a165c117f9627d1c Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 15 Mar 2019 15:42:09 -0400 Subject: [PATCH] Unregister tag selector when closed This restores the pre-Reactification behavior. --- .../content/zotero/containers/containers.js | 7 ++----- .../content/zotero/containers/tagSelector.jsx | 7 +------ chrome/content/zotero/zoteroPane.js | 21 ++++++++++++++----- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/chrome/content/zotero/containers/containers.js b/chrome/content/zotero/containers/containers.js index e0b8e39dd7..561048db77 100644 --- a/chrome/content/zotero/containers/containers.js +++ b/chrome/content/zotero/containers/containers.js @@ -33,10 +33,7 @@ ZoteroPane.Containers = { }, loadPane() { - var tagSelector = document.getElementById('zotero-tag-selector'); - ZoteroPane.tagSelector = Zotero.TagSelector.init(tagSelector, { - onSelection: ZoteroPane.updateTagFilter.bind(ZoteroPane) - }); + ZoteroPane.initTagSelector(); }, async initIntlStrings() { @@ -53,7 +50,7 @@ ZoteroPane.Containers = { }, destroy() { - ZoteroPane.tagSelector.unregister(); + ZoteroPane.tagSelector.uninit(); } } diff --git a/chrome/content/zotero/containers/tagSelector.jsx b/chrome/content/zotero/containers/tagSelector.jsx index 040942eaa0..f58c0f5cbf 100644 --- a/chrome/content/zotero/containers/tagSelector.jsx +++ b/chrome/content/zotero/containers/tagSelector.jsx @@ -189,18 +189,13 @@ Zotero.TagSelector = class TagSelectorContainer extends React.Component { this.state.viewOnly != (mode == 'view') && this.setState({viewOnly: mode == 'view'}); } - unregister() { + uninit() { ReactDOM.unmountComponentAtNode(this.domEl); if (this._notifierID) { Zotero.Notifier.unregisterObserver(this._notifierID); } } - uninit() { - this.setState({searchString: ''}); - this.selectedTags = new Set(); - } - handleTagContext = (tag, ev) => { let tagContextMenu = document.getElementById('tag-menu'); ev.preventDefault(); diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index a83e98a0f9..4e4c71708f 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -1088,21 +1088,32 @@ var ZoteroPane = new function() }; + this.initTagSelector = function () { + this.tagSelector = Zotero.TagSelector.init( + document.getElementById('zotero-tag-selector'), + { + onSelection: this.updateTagFilter.bind(this) + } + ); + }; + + this.toggleTagSelector = Zotero.Promise.coroutine(function* () { - var tagSelector = document.getElementById('zotero-tag-selector-container'); + var container = document.getElementById('zotero-tag-selector-container'); - var showing = tagSelector.getAttribute('collapsed') == 'true'; - tagSelector.setAttribute('collapsed', !showing); + var showing = container.getAttribute('collapsed') == 'true'; + container.setAttribute('collapsed', !showing); // If showing, set scope to items in current view // and focus filter textbox if (showing) { + this.initTagSelector(); yield this.setTagScope(); - ZoteroPane_Local.tagSelector.focusTextbox(); + ZoteroPane.tagSelector.focusTextbox(); } // If hiding, clear selection else { - ZoteroPane_Local.tagSelector.uninit(); + ZoteroPane.tagSelector.uninit(); } });