提交 f2507562 编写于 作者: E Eugene Pankov

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

上级 6a821fa6
.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
......
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' ...@@ -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)
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册