Skip to content

fix(note-widget): reinitialize markdown editor after async note load and workflow remount - #51

Open
prolps wants to merge 1 commit into
FreeterApp:masterfrom
prolps:fix/note-widget-markdown-remount
Open

prolps wants to merge 1 commit into
FreeterApp:masterfrom
prolps:fix/note-widget-markdown-remount

Conversation

@prolps

@prolps prolps commented Sep 1, 2026

Copy link
Copy Markdown

Summary

Fixes an issue where Markdown notes revert to plain text / raw textarea without formatting when switching workflows, changing projects, or remounting widgets after Memory Saver unmounts them.

Cause

In src/renderer/widgets/note/widget.tsx, the useEffect hook responsible for initializing TinyMDE only ran on initial mount when isLoaded was false (at which point textAreaRef.current was null).

Because isLoaded was missing from the hook's dependency array, the effect was never re-triggered once dataStorage.getText() resolved and the <textarea> actually rendered into the DOM. Consequently, the Markdown visual editor failed to attach upon subsequent workflow re-renders.

Solution

  1. Added isLoaded to the editor's useEffect dependency array so TinyMDE initializes immediately after the textarea DOM node is mounted.
  2. Added an idempotent cleanup routine (removeExistingEditorDOM) to prevent duplicate DOM nodes or memory leaks during component unmount/remount cycles.
  3. Explicitly typed the change event handler to comply with strict TypeScript/ESLint rules.

How to Test

  1. Create a Note Widget and enable Markdown in the widget settings.
  2. Add formatted Markdown text (headers, bold, checkboxes, lists).
  3. Switch to another Workflow or Project, then switch back.
  4. Verify that the formatted Markdown view renders immediately without falling back to the raw <textarea>.

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