Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect blur aka losing focus of a Draft.js editor

Is there a "correct way" to detect if I lose focus of a Draft.js editor?

The use case is, that I want "quit editor mode" if the user clicks elsewhere which means that I toggle the readOnly prop of the editor. How can I do this ideally and is it a good idea to do that (do you see problems with that)?

like image 845
Philip Claren Avatar asked Jul 03 '16 09:07

Philip Claren


1 Answers

You can catch the blur event fired around your draft editor just with a good old onBlur

<Editor onBlur={this.onBlur}

Isn't this enough for your scenario?

like image 186
goodhyun Avatar answered Oct 10 '22 14:10

goodhyun