I have input box like this,
I want to finish editing by pushing enter key or blur the input .
<input
ref={titleEditBox} type="text" onBlur={blurEditBox}
onKeyDown={keyDownFinishEdit}></input>
const blurEditBox = () =>{
finishEditbox();
}
const keyDownFinishEdit = (e) =>{
if (e.keyCode == 13){
finishEditText();
}
e.stopPropagation();
}
However when i push the return key it calles the keyDownFinishEdit
and then onBlur
so finishEditText()
is called twice.
So my idea is calling , unfocus from keyDownFinishEdit.
Is it possible or is there any good idea to sort out this?