Focus/touched detection

Hello, I would like to implement a “touched” detector for the validation of a form containing a text editor, and so I would need to know if the editor was once focused.

I found the focus() and focused() EditorView APIs but could not find some handleFocus() customizable prop in it. What would you recommend instead?

Answering myself, add a view prop:

handleDOMEvents: {
  focus: (view, event) => {
     this.wasFocused = true;
     return false;
  },
  blur: (view, event) => {
     if (this.wasFocused) {
       wasTouchedCallback();
     }
     return false;
  }
}
3 Likes