mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
finalised edit item page
This commit is contained in:
22
src/app/shared/utils/auto-focus.directive.ts
Normal file
22
src/app/shared/utils/auto-focus.directive.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Directive, AfterViewInit, ElementRef, Input } from '@angular/core';
|
||||
import { isNotEmpty } from '../empty.util';
|
||||
|
||||
@Directive({
|
||||
selector: '[dsAutoFocus]'
|
||||
})
|
||||
export class AutoFocusDirective implements AfterViewInit {
|
||||
|
||||
@Input() autoFocusSelector: string;
|
||||
|
||||
constructor(private el: ElementRef) {
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
if (isNotEmpty(this.autoFocusSelector)) {
|
||||
return this.el.nativeElement.querySelector(this.autoFocusSelector).focus();
|
||||
|
||||
} else {
|
||||
return this.el.nativeElement.focus();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user