I would like to prevent the default event from a focusOut
(or blur
) event and keep the focus set to the specific input field.
This is what I ha
I'm trying to achieve this behavior in a contenteditable element. I'd like to keep the cursor where it is while clicking outside buttons that shift the focus away from the contenteditable element.
As a solution, I intercept the focusout event and restore the original selection. Example in typescript:
editable_element.addEventListener('focusout',(e)=> {
if(e.relatedTarget && e.relatedTarget.tagName=="BUTTON")
{
let sel : any = App.SR.getSelection();
let range : any = sel.getRangeAt(0);
sel.removeAllRanges();
sel.addRange(range);
}
});