Skip to content

fix: text editor bugs found during exploratory testing - #3533

Merged
AlexAndBear merged 5 commits into
mainfrom
fix/text-editor-exploratory-findings
Oct 5, 2026
Merged

AlexAndBear merged 5 commits into
mainfrom
fix/text-editor-exploratory-findings

Conversation

@AlexAndBear

Copy link
Copy Markdown
Member

Description

Fixes found while exploratory testing the text editor (notes and markdown) with Playwright. One commit per bug:

What changed Why
Hydrating the editor now fails on content that doesn't fit the schema (errorOnInvalidContent) A note containing a node type the schema doesn't know (e.g. written by a newer version) opened as an empty, editable document without any warning. Saving then overwrote the whole file. It now goes through the existing hydration failure path: read-only plus "please reload" message, file untouched.
The Yjs session exposes flushContent() / hasPendingContent, the AppWrapper flushes before saving, autosaving, downloading and leaving Doc changes are reported to the wrapper with a 300 ms debounce. Pressing Ctrl+S right after typing did nothing (or saved the state without the last keystrokes), and pressing Esc right after typing closed the editor without the unsaved changes dialog, losing the input. beforeunload also treats a pending change as unsaved now. The route leave guard returns its result instead of calling next, since vue-router 5 rejects async guards that take next. "Cancel" in the dialog now aborts the navigation instead of leaving it pending.
Underline is no longer registered separately in the note and html strategies, @tiptap/extension-underline dependency dropped The StarterKit already ships it, tiptap warned about a duplicate extension on every editor mount. Toolbar button and Ctrl+U keep working.
OcEmojiPicker watches () => language.current language.current is a plain string, so the watch never fired on language changes (and Vue warned about an invalid watch source).

Related Issue

  • Fixes: no issue, found during exploratory testing

How Has This Been Tested?

  • test environment: local dev setup (Chrome via Playwright), unit tests via Vitest
  • test case 1: open a note with an unknown node type → editor is read-only with an error message, typing + Ctrl+S doesn't touch the file
  • test case 2: type and press Ctrl+S immediately → the last keystrokes are saved
  • test case 3: type and press Esc after ~100 ms → unsaved changes dialog shows; "Don't save", "Cancel" and "Save" behave correctly, closing again after "Cancel" works
  • test case 4: underline via toolbar and Ctrl+U in a note, no duplicate extension warning
  • test case 5: unit tests for hydration of invalid content, flushing pending changes on Ctrl+S and route leave, and the emoji picker language change

Types of changes

  • Bugfix
  • Enhancement (a change that doesn't break existing code or deployments)
  • Breaking change (a modification that affects current functionality)
  • Technical debt (addressing code that needs refactoring or improvements)
  • Tests (adding or improving tests)
  • Documentation (updates or additions to documentation)
  • Maintenance (like dependency updates or tooling adjustments)

}

// `beforeunload` can't wait for a flush, so a pending change counts as unsaved there
const hasUnsavedWork = computed(() => unref(isDirty) || unref(yjsSession?.hasPendingContent))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to check for (!isReadOnly && hasPendingContent) because hasPendingContent evaluates for read-only users as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed in 0bbf82e. I used the permission-based isReadOnly rather than effectiveReadOnly, because a session that locks for reload mid-edit must keep the unload guard armed. Added a test for the read-only case.

@AlexAndBear
AlexAndBear requested a review from JammingBen October 5, 2026 12:36
@AlexAndBear
AlexAndBear merged commit 6e175ab into main Oct 5, 2026
31 checks passed
@AlexAndBear
AlexAndBear deleted the fix/text-editor-exploratory-findings branch October 5, 2026 15:07
@openclouders openclouders mentioned this pull request Oct 5, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants