View.focus but but not has cursor in content

what i expected is view.focus() can has a cursor in content however, focus not has cursor but seems already worked. in browser continuely ctrl-v my Slice, new Slice do added instead of replace last added slice after call view.focus in nodeview, but do not show a expected blinking cursor at the end of the new slice

am i missing something from the manual ?

what i do is

if (isPaste) {
      const selection = Selection.atEnd(view.docView.node)
      const tr = view.state.tr.setSelection(selection, 1).scrollIntoView()
      const state = view.state.apply(tr)
      view.updateState(state)
    }

view.docView isn’t part of the public interface, so just use view.state.doc instead. setSelection doesn’t have a second argument. And the last two lines can be replaced by simply view.dispatch(tr).

But none of those seem like they are the problem. Where are you calling this code? And could you describe what goes wrong more clearly, since I don’t see the connection between focus and the code you are showing.

Hi marijn, I think what @zlv-thisF was trying to say is. the focus event not triggered. When mannually call the view.focus() function.

Let’s say we have a plugin just as follows: the console.log(event) not called. (no blink cursor in the edit area) But when you check the view.hasFocus() status it’s true.

Otherwise, click the editor edit area by mouse DO trigger the focus event and console.log(event);

let focusPlugin = new Plugin({
  props {
    handleDOMEvents: {
      focus: (view, event) => {
        console.log(event);
      }
    }
  }
});