Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Cannot focus() if editor is initialized empty #446

Closed
2 tasks done
braincore opened this issue May 3, 2024 · 1 comment
Closed
2 tasks done

[BUG] Cannot focus() if editor is initialized empty #446

braincore opened this issue May 3, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@braincore
Copy link
Contributor

If you want to ask for support or request features, sponsor the project and contact me over email.

  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • I have read the documentation and cannot find an answer.

Describe the bug
If an editor is initialized with prop markdown="", then a call editor method focus() will fail to focus the editor.

Reproduction
Sandbox: Simply click "Test focus"

Expected behavior
Editor should be brought to focus with blinking cursor at start index.

Additional context
This issue came up in the context of calling "focus()" from a mobile-web interface to bring up the virtual keyboard.

@braincore braincore added the bug Something isn't working label May 3, 2024
@braincore
Copy link
Contributor Author

As a workaround, setMarkdown() can be called prior to calling focus(). However, setMarkdown() must have contents (at least temporarily)! To avoid any visual artifacts, one can do the following:

mdxEditorRef.current.setMarkdown("  ");
mdxEditorRef.current.setMarkdown("");

@petyosi petyosi closed this as completed in 77b3acb May 4, 2024
petyosi added a commit that referenced this issue May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant