froala / angular-froala

Angular.js bindings for Froala WYSIWYG HTML Rich Text Editor.
https://froala.com/wysiwyg-editor
MIT License
306 stars 123 forks source link

Editor not focused when init on click #159

Closed FWennerdahl closed 6 years ago

FWennerdahl commented 6 years ago
Expected behavior.

When using the initOnClick functionality, the editor should gain focus when clicked like it does when not using AngularJS.

Actual behavior.

When using the angular-froala bindings, the editor does not get focused when initializing on click.

Steps to reproduce the problem.

JSFiddle angular-froala: https://jsfiddle.net/Lty2xz7e/ JSFiddle vanilla Froala: https://jsfiddle.net/2h5aeoz2/

  1. Start the angular-froala JSFiddle above.
  2. Click the editor.
  3. Click outside the editor. Since the editor didn't get focus when clicked, the blur event is not triggered.

Repeating the same steps with the vanilla Froala JSFiddle above, the editor does get focus when initialized and the blur event is triggered when clicking somewhere else.

Use-case: We're using the blur event to destroy and reinitialize the editors to avoid having more than one active editor at a time on the same page. Since the editor doesn't get focus the event isn't triggered and multiple instances can be opened at the same time.

OS.

macOS 10.12.6 Sierra

Browser.

Chrome 62.0.3202.94

stefanneculai commented 6 years ago

It appears to be an issue on the Angular implementation, not related to #2283.

Eblax commented 6 years ago

I have the same issue. Also when I set focus manually with $('selector').froalaEditor('events.focus'); the editor does get focus, but the froalaEditor.focus event is not triggered. This could explain why the froalaEditor.blur event is also not triggered once I click outside the editor.

FWennerdahl commented 6 years ago

Tested and works. Thanks!