From 4a856b94cc2b24478127b741cb8f380bbd4dce8c Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Wed, 25 May 2022 13:22:52 -0600 Subject: [PATCH] fx-compat: Item box: Fix abstract expander --- chrome/content/zotero/elements/itemBox.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/chrome/content/zotero/elements/itemBox.js b/chrome/content/zotero/elements/itemBox.js index 65a10852f5..fd37af316f 100644 --- a/chrome/content/zotero/elements/itemBox.js +++ b/chrome/content/zotero/elements/itemBox.js @@ -585,7 +585,7 @@ } else { this.getRootNode().host.toggleAbstractExpand( - this, this.closest('tr').querySelector('.value') + this.firstElementChild, this.closest('tr').querySelector('.value') ); } }); @@ -1264,14 +1264,14 @@ 'abstractNote', tabindex ); - valueElement.parentNode.replaceChild(newValueElement, valueElement); + valueElement.replaceWith(newValueElement); var text = Zotero.ItemFields.getLocalizedString('abstractNote'); // Add '(...)' before "Abstract" for collapsed abstracts if (valueText && cur) { text = '(\u2026) ' + text; } - label.setAttribute('value', text); + label.textContent = text; } disableButton(button) { @@ -1401,23 +1401,25 @@ valueElement.textContent = valueText; - if ((firstSpace == -1 && valueText.length > 29 ) || firstSpace > 29 + if (isMultiline) { + valueElement.classList.add('multiline'); + } + + if ((firstSpace == -1 && valueText.length > 29) || firstSpace > 29 || (fieldName && - (fieldName.substr(0, 7) == 'creator') || fieldName == 'abstractNote')) { + (fieldName.startsWith('creator') || (!isMultiline && fieldName == 'abstractNote')))) { if (fieldName == 'abstractNote') { valueText = valueText.replace(/[\t\n]/g, ' '); } valueElement.setAttribute('crop', 'end'); } - else if (isMultiline) { - valueElement.classList.add('multiline'); - } // Allow toggling non-editable Abstract open and closed with click if (fieldName == 'abstractNote' && !this.editable) { valueElement.classList.add("pointer"); valueElement.addEventListener('click', () => { - this.toggleAbstractExpand(valueElement.previousSibling, valueElement); + let label = valueElement.parentElement.previousElementSibling.firstElementChild; + this.toggleAbstractExpand(label, valueElement); }); }