plane icon indicating copy to clipboard operation
plane copied to clipboard

[WIKI-770] fix: update editor ref after editor ready

Open iam-vipin opened this issue 2 months ago β€’ 2 comments

Description

improve how the editor reference (editorRef) is managed and initialized, especially when the editor is ready.

Type of Change

  • [x] Bug fix (non-breaking change which fixes an issue)

Screenshots and Media (if applicable)

https://github.com/user-attachments/assets/fe2cca22-0821-416b-8ebf-29fc321e84ac

Test Scenarios

References

Summary by CodeRabbit

  • Refactor
    • Enhanced editor reference management and command execution in the text editor component to improve toolbar interaction handling.

iam-vipin avatar Nov 14 '25 09:11 iam-vipin

Linked to Plane Work Item(s)

This comment was auto-generated by Plane

makeplane[bot] avatar Nov 14 '25 09:11 makeplane[bot]

Walkthrough

The editor reference handling is refactored from relying on a forwarded ref to using local state. A handleEditorReady callback initializes the local editorRef state when the editor mounts, which is then used by toolbar components to execute commands instead of accessing the forwarded ref directly.

Changes

Cohort / File(s) Summary
Editor Reference State Management
apps/web/core/components/editor/lite-text/editor.tsx
Introduces local editorRef state initialized to null and adds handleEditorReady callback to populate it when the editor is ready; replaces forwarded ref access with local state in toolbar command execution flows via LiteToolbar and IssueCommentToolbar

Sequence Diagram(s)

sequenceDiagram
    participant Editor as LiteTextEditorWithRef
    participant Handler as handleEditorReady
    participant State as editorRef State
    participant Toolbar as Toolbar Components

    Editor->>Editor: Component mounts
    Editor->>Handler: Editor ready event fires
    Handler->>State: Set editorRef with editor instance
    State->>Toolbar: editorRef state available
    Toolbar->>Toolbar: User triggers toolbar action
    Toolbar->>State: Access editorRef
    State->>Toolbar: Return editor reference
    Toolbar->>Editor: executeMenuItemCommand()

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single file with focused state management refactor
  • Clear pattern: forwarded ref β†’ local state initialization
  • Primary concern: verify toolbar interactions work correctly with the new state dependency; ensure no race conditions between editor ready callback and toolbar access

Poem

🐰 A hop and a state, the ref finds its place,
No longer adrift in the forwarded space,
When editors wake, the commands take flight,
Local state captures the moment just right!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
βœ… Passed checks (2 passed)
Check name Status Explanation
Title check βœ… Passed The title clearly and concisely summarizes the main change: updating the editor ref after the editor is ready.
Description check βœ… Passed The description covers the main change and includes type of change checkbox, but lacks test scenarios and issue references despite template sections for these.
✨ Finishing touches
  • [ ] πŸ“ Generate docstrings
πŸ§ͺ Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch fix-comment_cta

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Nov 14 '25 09:11 coderabbitai[bot]