Skip to content

fix(ui): safeguard attachment rendering and tiptap editor teardown - #8396

Open
aquananu wants to merge 1 commit into
nextcloud:mainfrom
aquananu:fix/tiptap-attachment-nullchecks
Open

aquananu wants to merge 1 commit into
nextcloud:mainfrom
aquananu:fix/tiptap-attachment-nullchecks

Conversation

@aquananu

Copy link
Copy Markdown
Contributor
  • Resolves: #
  • Target version: main

Summary

This PR resolves multiple client-side reactivity exceptions and unhandled teardown crashes in Nextcloud Deck:

  1. Fix Attachment List Rendering & Null Safety (src/components/card/AttachmentList.vue):

    • Lines 49–51: Added optional chaining for attachment.extendedData?.filesize and attachment.extendedData?.attachmentCreator?.displayName to prevent template render errors when attachments lack metadata.
    • Line 159: Added null-safety check for attachment?.extendedData?.hasPreview and attachment?.extendedData?.mimetype in mimetypeForAttachment.
    • Lines 167–176: Added null-safe checks and fallback links (#) in attachmentPreview, attachmentUrl, internalLink, and downloadLink (attachment?.extendedData?.path).
    • Lines 196–201: Resolved TypeError: Cannot read properties of undefined (reading 'filename') in attachmentBasename and attachmentExtension by using optional chaining (attachment?.extendedData?.info?.filename ?? (attachment?.name ?? attachment?.data ?? '').replace(...)).
  2. Fix Card Sidebar Watcher Crash on Card Deselection (src/components/card/CardSidebar.vue):

    • Lines 210–214: Resolved TypeError: Cannot read properties of undefined (reading 'id') in the currentCard(newCard, oldCard) watcher when closing a card modal or clearing selection (newCard becoming null/undefined). Now safely evaluates newCard?.id === oldCard?.id and only invokes focusHeader() when newCard is present.
  3. Fix Tiptap Rich Text Editor Unmount Teardown and Race Conditions (src/components/card/Description.vue):

    • Lines 186–192: Guarded this.editor.setContent(...) in the card watcher with a method existence check and try...catch to prevent invocation during disposal.
    • Lines 208–248: Added unmount guards (this._isBeingDestroyed || this._isDestroyed) in setupEditor(). If a card modal is closed while OCA.Text.createEditor(...) is still resolving, the newly created editor is destroyed immediately rather than retained on an unmounted DOM ref.
    • Lines 249–262: Resolved [tiptap error]: The editor view is not available. Cannot access view['dom'] in destroyEditor() by immediately nullifying this.editor and wrapping editor.destroy() in a try...catch block.
    • Lines 302–305: Handled missing extendedData.info safely when formatting fileName in addAttachment.

TODO

  • Null-check attachment information and download URLs (AttachmentList.vue:49-51, 159, 167-176, 196-201)
  • Safeguard currentCard watcher in sidebar (CardSidebar.vue:210-214)
  • Guard Description rich text editor setup and teardown against unmounted states (Description.vue:186-192, 208-262, 302-305)
  • Backport to stable branches (stable34, etc.)

Checklist

  • Code is properly formatted (npm run lint passes with 0 errors)
  • Sign-off message is added to all commits (git commit -s)
  • Tests (unit, integration, api and/or acceptance) are included or verified manually
  • Documentation (manuals or wiki) has been updated or is not required

- Guard AttachmentList against missing extendedData and info properties
- Guard CardSidebar currentCard watcher when card is deselected
- Safeguard Description editor setup and teardown against unmounted states

Signed-off-by: aquananu <AQUANANU@GMAIL.COM>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant