force autofocus in rename-tab modal (fixes #484)

This commit is contained in:
Eugene Pankov
2018-10-29 16:45:51 +01:00
parent 6a821fa6cf
commit f250756254
2 changed files with 9 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
.modal-body .modal-body
input.form-control(type='text', [(ngModel)]='value', (keyup.enter)='save()', autofocus) input.form-control(type='text', #input, [(ngModel)]='value', (keyup.enter)='save()', autofocus)
.modal-footer .modal-footer
button.btn.btn-outline-primary((click)='save()') Save button.btn.btn-outline-primary((click)='save()') Save

View File

@@ -1,4 +1,4 @@
import { Component, Input } from '@angular/core' import { Component, Input, ElementRef } from '@angular/core'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
@Component({ @Component({
@@ -7,11 +7,18 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
}) })
export class RenameTabModalComponent { export class RenameTabModalComponent {
@Input() value: string @Input() value: string
@ViewChild('input') input: ElementRef
constructor ( constructor (
private modalInstance: NgbActiveModal private modalInstance: NgbActiveModal
) { } ) { }
ngOnInit () {
setTimeout(() => {
this.input.nativeElement.focus()
})
}
save () { save () {
this.modalInstance.close(this.value) this.modalInstance.close(this.value)
} }