Skip to content

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

Open
aquananu wants to merge 3 commits into
nextcloud:mainfrom
aquananu:fix/tiptap-attachment-nullchecks
Open

aquananu wants to merge 3 commits 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>
@aquananu

Copy link
Copy Markdown
Contributor Author

same error exist in Deck version 1.18.5 too

Signed-off-by: aquananu <93096176+aquananu@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant