简体   繁体   中英

angular 2 material input default focus remove

I have one dialog with one text input , some radio buttons and ok cancel. When the dialog open the cursor is blinking inside the text input which means the placeholder text has zoomed out and hard to read. placeholder text is something like 'Describe details of the issue in this box'. How can I remove default autofocus in angular 2 ? As a hack even if I can somehow make the placeholder not zoom out I am good. Please advise. Using angular material controls.

Another solution is setting the dialog's inputs' tabindex to -1.

<button tabindex="-1" #closeAuthPanelButton mat-icon-button>
  <mat-icon (click)="emitAuthPanelClose()">close</mat-icon>
</button>

In the config object you pass after the component in dialog.open() you can set the autofocus property to false .

this.dialog.open(SomeComponent, {
  width: '100px',
  data: {},
  autoFocus: false
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM