From 98a0699f8556545687891966e4122723a292ca87 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 15 Nov 2019 04:06:21 -0500 Subject: [PATCH] Properly disable React tags box in read-only mode --- chrome/content/zotero/components/editable.jsx | 4 ++-- .../content/zotero/components/itemPane/tagsBox.jsx | 13 ++++++++----- chrome/content/zotero/containers/tagsBox.xul | 3 ++- chrome/content/zotero/itemPane.js | 7 +++++++ 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/chrome/content/zotero/components/editable.jsx b/chrome/content/zotero/components/editable.jsx index eb170f9110..bf6f6627a0 100644 --- a/chrome/content/zotero/components/editable.jsx +++ b/chrome/content/zotero/components/editable.jsx @@ -80,10 +80,10 @@ class Editable extends React.PureComponent { } render() { - const { isDisabled } = this.props; + const { isDisabled, isReadOnly } = this.props; return (
this.props.onClick(event) } onFocus={ event => this.props.onFocus(event) } onMouseDown={ event => this.props.onMouseDown(event) } diff --git a/chrome/content/zotero/components/itemPane/tagsBox.jsx b/chrome/content/zotero/components/itemPane/tagsBox.jsx index 09672acb11..9e20af4d6f 100644 --- a/chrome/content/zotero/components/itemPane/tagsBox.jsx +++ b/chrome/content/zotero/components/itemPane/tagsBox.jsx @@ -85,6 +85,9 @@ const TagsBox = React.forwardRef((props, ref) => { } function handleEdit(event) { + if (!props.editable) { + return; + } if (skipNextEdit.current) { skipNextEdit.current = false; return; @@ -349,13 +352,13 @@ const TagsBox = React.forwardRef((props, ref) => { title={title} tooltiptext={title} style={{ width: "16px", height: "16px" }} - onClick={() => setSelectedTag(tag.tag)} + onClick={props.editable ? (() => setSelectedTag(tag.tag)) : undefined} />
{
{renderCount()}
-
+ { props.editable &&
}
    {displayTags.map(tag => renderTagRow(tag))}
- + /> }
); diff --git a/chrome/content/zotero/containers/tagsBox.xul b/chrome/content/zotero/containers/tagsBox.xul index ad1a4065a1..ff69329398 100644 --- a/chrome/content/zotero/containers/tagsBox.xul +++ b/chrome/content/zotero/containers/tagsBox.xul @@ -30,7 +30,8 @@ - + diff --git a/chrome/content/zotero/itemPane.js b/chrome/content/zotero/itemPane.js index d21d4d12e0..7bb2c24e07 100644 --- a/chrome/content/zotero/itemPane.js +++ b/chrome/content/zotero/itemPane.js @@ -324,6 +324,13 @@ var ZoteroItemPane = new function() { } + this.onTagsContextPopupShowing = function () { + if (!_lastItem.editable) { + return false; + } + } + + this.removeAllTags = async function () { if (Services.prompt.confirm(null, "", Zotero.getString('pane.item.tags.removeAll'))) { _lastItem.setTags([]);