How to autofocus in CM6

trying to put .focus() at instance of new EditorView(), but not work.
i read the doc, and not sure how to usage. thank you.

The browser will often interfere with focus during document loading. Delaying your call to focus until a bit after the page has loaded might help.

FYI: Here is my solution (similar to old autofocus?):

    const timer = setInterval(() => {
        if(editor.hasFocus) clearInterval(timer);
    }, 500);
1 Like