isSnapshotAttachment() checks the link mode (needs to be IMPORTED_URL),
but we actually allow viewing all attachments with text/html MIME types
as "snapshots" in the reader. Don't throw on any HTML attachment that
the reader is willing to open.
- 59afef6 added a duplicate assignment to item.rights that was putting
a TextConstruct(!!!!) in the item JSON field instead of a string
- info.rights was being set to a TextConstruct (preexisting issue!)
The 'blur' event needs to be dispatched by editable-text
before its state is reset (not after) because tagsbox uses
.initialValue in the 'blur' handler.
followup to 101e6d55d5Fixes: #3575
- fix the infinite loop glitch. Tweak of editable-text to only
dispatch 'blur' event if the input was actually blured. It prevents
the hideEditor from being locked in an infinite loop due to the
call stack hideEditor -> modifyCreator -> moveCreator -> blur -> hideEditor
- refactor blurOpenField to not be async and to not be used in most
places. It is mainly redundant now that editable-text handles blur
if clicked anywhere outside of it, so it helps to avoid confusion.
- since moveCreator does not await or yield for anything anymore, remove the
Zotero.spawn part. The rest of the function is unchanged.
- on focusin of the empty unsaved creator row, use its future unsaved id
that reflects its positioning instead of its real id (which technically is
the very last creator row). That way, a tab from a creator row that was just
filled will land to the proper component after render, as opposed to
focusing the very last row.
- similar approach to removing the unsaved creator row when the focus is
in it - focus the row above it, as opposed to the last row.
Fixes: #4145
Addresses part of: #4143
- plus button is enabled on all creator rows, not just the last one
- enabled plus button will add an empty unsaved creator row below
current creator row. After that, plus button is disabled as long as
the next row is unsaved.
- the grippy of a newly added unsaved row is disabled
- adding an unsaved creator row will remove another unsaved creator row
if one exists. That way, only one unsaved row can exist at a time
- once the unsaved creator row is added, it is tentatively perceived as
the "last" creator row based on its id. That is to avoid shifting all
other creators' indicies and saving the item too many times. When the
field is blurred, that new creator is moved into its "unsavedIndex"
before saving the item
Fix to a glitch where after switching creator field mode, the
autocomplete suggestions for creators would still be for the old mode.
This only happened if the field mode was changed on an empty, unsaved
creator row.
- removed ztabindex logic from itemBox. It is no longer needed, adds
unnecessary complexity and is likely at the root of multiple glitches
if a plugin inserts an arbitrary row that does not have ztabindex set.
- if a creator row is deleted when the focus is inside of the row, focus
another creator row to not loose the focus.
- more centralized button handling in `_ensureButtonsFocusable` and
`_updateCreatorButtonsStatus`
- refactoring of hidden toolbarbuttons css so that the icons are still
hidden and don't occupy space (if desired) but are still visible for
screen readers, so they are focusable without JS changing their
visibility (this with ztabindex removal fixes vpat 24)
- removed `escape_enter` event from `editable-text`. It was a workaround
to know when itemBox should move focus back to itemTree. Unhandled
Enter on an input or Escape should focus itemTree (or reader) from
anywhere in the itemPane/contextPane (not just itemBox), so that logic
is moved to itemDetails.js. To avoid conflicts with Shift-Enter, do
not propagate that event outside of multiline editable-text. Fixes:
#3896
- removed not necessary keyboard nav handling from itemDetails.js. It
was only needed for mac, and is redundant if "Keyboard navigation"
setting is on
- using `keydown` instead of `keypress` for itemDetails keyboard nav
handling because `Enter` `keypress` does not seem to get out of
`editable-text` but `keydown` does.
- old handleKeyPress from itemBox is no longer relevant for most
elements, so it is removed and substituted with a dedicated handler
just for creator row.
- moved the creator's paste handler into its own dedicated function
from the autocomplete handler (which was confusing)
- special handling for `enter` and `escape` events on `editable-text`
with autocomplete to not stop event propagation, so that the events
can bubble and be handled in `itemDetails`. It avoids some cases of
the focus being lost and returned to the `window`. It was unnecessary
earlier due to `escape_enter` workaround but only within itemBox and
only within itemPane.
- removed explicit tab navigation handling from `collapsible-section`
header. Currently, it may get stuck when buttons are hidden (e.g. in
the trash mode). It was only added to enable keyboard navigation on
mac before special "Keyboard navigation" setting was discovered (it
was never an issue on windows), so now it's easier to just let mozilla
handle it.
- always use `getTitleField` to find and focus the proper title field in
itemBox
- on shift-tab from the focused tab, just move focus to the first
focusable element before the splitter without any special handling for
attachments, notes and duplicates pane as before. It ensures a more
consistent and predictable keyboard navigation, especially now that
itemPane is fairly keyboard accessible.
Fixes: #4076
:focus-within doesn't match when the window is inactive but the field
is focused.
Addresses #4101, except that focusing the new item's title field and
pressing Escape will clear the field (without modifying the item).
If a parent item and its primary attachment are selected, it should
still say "Show File" rather than "Show Files". This adds the
questionably named `Zotero.Items.numDistinctFileAttachmentsForLabel()`
to try to figure out if we're operating on 0, 1, or >1 items.
Follow-up to #4124