fx115: fix tags autocomplete breakage (#3882)

With fx115, changes from 49fe2b98d9
made the autocomplete popup appear blank when the reader tab is opened.
Not re-creating the PopupAutoComplete in tagsBox makes the items from
autocomplete popup visible again. But it makes the autocomplete appear
below the "Add tags" popup for annotations (what 49fe2b98d9
originally fixed), and it also creates a duplicate <popupset>
with a new autocomplete panel at the bottom of the DOM every time autocomplete runs.
The duplicate <panel>s do not have an id.

Manually adding a <popupset> with a <panel> whose id="PopupAutoComplete"
does not create any duplicates and properly positions the popup.

Fixes: #3881
This commit is contained in:
abaevbog 2024-03-29 06:47:27 -04:00 committed by Dan Stillman
parent 98ed686212
commit 89320a7ee4
2 changed files with 14 additions and 20 deletions

View file

@ -64,26 +64,6 @@
removeAllItemTags.disabled = !this.count;
this._id('tags-context-menu').openPopupAtScreen(event.screenX, event.screenY, true);
});
if (!document.getElementById('PopupAutoComplete')) {
let popupset = document.querySelector('popupset');
if (!popupset) {
popupset = document.createXULElement('popupset');
document.documentElement.append(popupset);
}
let autocomplete = document.createXULElement('panel', { is: 'autocomplete-richlistbox-popup' });
autocomplete.id = 'PopupAutoComplete';
autocomplete.setAttribute('type', 'autocomplete-richlistbox');
autocomplete.setAttribute('role', 'group');
autocomplete.setAttribute('noautofocus', true);
autocomplete.setAttribute('hidden', true);
autocomplete.setAttribute('overflowpadding', 4);
autocomplete.setAttribute('norolluponanchor', true);
autocomplete.setAttribute('nomaxresults', true);
popupset.append(autocomplete);
}
// Register our observer with priority 101 (after Zotero.Tags) so we get updated tag colors
this._notifierID = Zotero.Notifier.registerObserver(this, ['item-tag', 'setting'], 'tagsBox', 101);
}

View file

@ -1305,4 +1305,18 @@
</stack>
</vbox>
</hbox>
<!-- fx115: the popupset has to be here to properly display autocomplete popup -->
<popupset>
<panel
is="autocomplete-richlistbox-popup"
type="autocomplete-richlistbox"
id="PopupAutoComplete"
role="group"
noautofocus="true"
hidden="true"
overflowpadding="4"
norolluponanchor="true"
nomaxresults="true"
/>
</popupset>
</window>