Detect blur aka losing focus of a Draft.js editor
Asked Answered
T

1

7

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)?

Thermal answered 3/7, 2016 at 9:15 Comment(0)
M
14

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?

Mantle answered 4/8, 2016 at 16:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.