angular-editor icon indicating copy to clipboard operation
angular-editor copied to clipboard

Focus appears to be broken

Open Gaugeforever opened this issue 3 years ago • 7 comments

I seem to be unable to focus the text area no matter what method I use and it was previously working. Can someone provide a working example of focusing the text area upon init so the user can simply start typing?

Gaugeforever avatar Jul 11 '21 17:07 Gaugeforever

I'm also facing the same problem. Can't type anything in the editor right after page is rendered. The editor allows to type in something only after "swapping to html view and then back to the normal view".

sranjan-m avatar Jul 27 '21 07:07 sranjan-m

Hello i was having the same issue, so i made a workaround on my side to synchronize toolbar part and editor part : Html part :

<form [formGroup]="modelGroup" (ngSubmit)="onSave()" >
  <div>
        <angular-editor  #editor formControlName="value" [config]="editorConfig"></angular-editor>
  </div>
  <button class="btn btn-primary btn-block-rwd" type="submit" >Save</button>
</form>

Ts part

 @ViewChild("editor") editor;

 onSave(): void {
    //saving part on server side 
...
  // then if editor was on html mode, go back to it 
    if (this.editor.modeVisual == false) {
      this.editor.modeVisual = true;
      this.editor.editorToolbar.triggerCommand("toggleEditorMode");
    }
  }

LogainStark avatar Sep 29 '21 17:09 LogainStark

I should have posted this long time ago, but somehow missed it out.

editorConfig: AngularEditorConfig = {
  editable: true
};

Setting the above config solved the problem. Not sure why editable has to be set manually to true. By default it's suppose to be true in the component itself, but anyways hope this helps.

sranjan-m avatar Sep 30 '21 10:09 sranjan-m

None of these options work and I have ensured I have the latest version. I did some testing and this prints false.

this.angularEditor.focus(); console.log(this.angularEditor.focused);

I have tried this even on ngAfterViewInit on the component that houses the angular editor. The bottom line is that it is not possible to focus the text area for whatever reason and this needs to be fixed.

Gaugeforever avatar Oct 14 '21 13:10 Gaugeforever

<angular-editor id="aEditor" [config]="wysiwygConfig" ></angular-editor>
export class ZoFieldWisywig implements OnInit {
  wysiwygConfig: AngularEditorConfig = {
    editable: true,
    height: '15rem',
    minHeight: '10rem',
    placeholder: 'Enter text here...'
  };
  ngOnInit(): void {
    
  }
}

Have you tried like this? Manage the model bindings according to Template driven Form or Reactive Form.

sranjan-m avatar Oct 15 '21 06:10 sranjan-m

Yes I have tried this. The developer seems to have abandoned this project, no responses from them and pull requests aren't being approved so we're just going to pull the entire code base into our project and fix it ourselves. Good luck everyone.

Gaugeforever avatar Oct 15 '21 16:10 Gaugeforever

I should have posted this long time ago, but somehow missed it out.

editorConfig: AngularEditorConfig = {
  editable: true
};

Setting the above config solved the problem. Not sure why editable has to be set manually to true. By default it's suppose to be true in the component itself, but anyways hope this helps.

Well that's.. funny, but I'm glad it worked so, thank you very much!

s-gbz avatar May 28 '22 23:05 s-gbz