question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do I prevent the Toast UI Editor from getting focus when it is rendered

See original GitHub issue

Summary

I have a NextJS app that contains the toast-ui/react-editor. The editor is not visible and I have a button that controls visibility by toggling the show state variable this way:

export function MyEditor({placeholder}) {
const [show, setShow] = useState(false);
const editorRef = useRef(null);

  return (
    <div class="root">
      <div class="editor-container">
        {show && <Editor
              ref={editorRef}
              placeholder={placeholder}
              previewStyle='tab'
              theme='dark'
              minHeight='300px'
              height='300px'
              initialEditType='markdown'
              hooks={{
                addImageBlobHook: onAddImageBlob,
              }}
              autofocus={false}
        />}
      </div>
    </div>
  );
}

Please note that I am passing the autofocus property false but the editor’s text area gets activated as soon as the editor is rendered.

How do I turn it off?

Version

"@toast-ui/editor": "^3.1.0",
"@toast-ui/react-editor": "^3.1.0",

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
suregicommented, Sep 30, 2021

I have the same issue. This happens when previewStyle is the “tab”. Seems ok with “vertical” or when initialEditType is “wysiwyg”. Here’s the simplest dupe code:

<Editor
	previewStyle="tab"
	initialEditType="markdown"
	initialValue={'abc'}
	events={{
		focus: () => {
			console.log('⭐ focus');
		},
	}}
	autofocus={false}
/>
0reactions
livevsonlinecommented, Aug 24, 2022

Oh, its now has an option called autofocus in the oSettings object

Read more comments on GitHub >

github_iconTop Results From Across the Web

Editor | TOAST UI :: Make Your Web Delicious!
The Editor allows you to edit your Markdown documents using text or WYSIWYG and comes with Syntax Highlighting, Scroll-Sync, Live Preview, ...
Read more >
How do I prevent toast from taking away focus?
I'm doing an auto-save onchange of an input and toasting a “Saved” message, but if the user clicks onto the next input (triggering...
Read more >
[Release News] TOAST UI Editor 3.0 is here!
Customizing the editor using options and APIs as users is a painstaking task. If a user were to customize a certain node's rendered...
Read more >
@toast-ui/react-editor | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Documentation: DevExtreme - JavaScript Data Grid Methods
Adds an empty data row and switches it to the editing state. ... The beginUpdate() and endUpdate() methods prevent the UI component from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found