angular-editor
angular-editor copied to clipboard
blur event doesn't work if you click on something that doesn't have a tabindex property
this:
https://github.com/kolkov/angular-editor/blob/master/projects/angular-editor/src/lib/angular-editor.component.ts#L170
test for relatedTarget, but that is only set when the thing you click on als has a tabindex, which doesn't have to be if you just click on a div (kind of empty space)
I would like that blur() is always triggered
What i really am trying todo is have a change event. But i don't seem to be really be able todo this. (change)="updated()" doesn't work, (ngModelChange)="updated()" does work but that is fired constantly when typing, i don't want that i want a "edit complete" event
So thats why i try blur and when it is blurred i just see it as a change, but also that doesn't work all the time..
i think this code:
if (event.relatedTarget !== null) { const parent = (event.relatedTarget as HTMLElement).parentElement; if (!parent.classList.contains('angular-editor-toolbar-set') && !parent.classList.contains('ae-picker')) { this.blurEvent.emit(event); this.focused = false; } }
is trying to see if the toolbar is clicked and then don't call blur, but i think it should be a bit different.. like having an else that really just does: else { this.blurEvent.emit(event); this.focused = false; }
Thanks! Here we need to think very well how to do it right and so that nothing will break in the end.
i think just adding that else is even fixing more. Because the boolean "this.focused" is kept on true even.. so i clicked really outside of the editor completely somewhere else (but not on something that has a tabindex) then that is not set to false
so here: https://github.com/kolkov/angular-editor/blob/master/projects/angular-editor/src/lib/angular-editor.component.ts#L137
you don't handle the focus event that it really did get it again.. because it still thinks it had the focus.
also what is that "this.changed" (not directly related to this but it is used in the focus stuff) Because that is set to false in the constructor then set to true once in onContentChange() method (so the first change will set that to true) then it is never set to false again, and i have a feeling that that should be the case, or is this really a 1 time thing? (that configure() is really just a one time call, but what is then "this.touched" because it seems to me that configure() is called twice.. 1 time when this.touched is false on the first focus gained, then as long as the content didn't change it also call configure everytime it gained focus? (but maybe content change is called very soon also, if we just change the input to its first value) )
edit: yes configure() is called constantly when it did get focus (so i clicked on something with a tabindex) until i really did a change and from that on it is never called again. this seems a bit weird to me.
Still not working at v1.2.0. Any suggestions on this issue?