Skip to content

Commit

Permalink
fix: trap focus inside bootstrap container - fixes #113
Browse files Browse the repository at this point in the history
  • Loading branch information
Shlomi Assaf (shlassaf) committed Jun 14, 2016
1 parent 52c759e commit c7113b4
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
ReflectiveInjector,
ViewChild,
ViewEncapsulation,
AfterViewInit
AfterViewInit,
ElementRef
} from '@angular/core';

import { DialogRef, ModalCompileConfig } from '../../angular2-modal';
Expand Down Expand Up @@ -48,6 +49,7 @@ export class BSModalContainer implements AfterViewInit {
@ViewChild('modalDialog', {read: ViewContainerRef}) private _viewContainer: ViewContainerRef;

constructor(public dialog: DialogRef<BSModalContext>,
private el: ElementRef,
private _compileConfig: ModalCompileConfig,
private _modal: Modal,
private _cr: ComponentResolver) {
Expand All @@ -67,8 +69,12 @@ export class BSModalContainer implements AfterViewInit {

const childInjector = Array.isArray(bindings) && bindings.length > 0 ?
ReflectiveInjector.fromResolvedProviders(bindings, ctxInjector) : ctxInjector;
return this.dialog.contentRef =
vcr.createComponent(cmpFactory, vcr.length, childInjector);

if (this.el.nativeElement) {
this.el.nativeElement.focus();
}

this.dialog.contentRef = vcr.createComponent(cmpFactory, vcr.length, childInjector);
});
}

Expand Down

0 comments on commit c7113b4

Please sign in to comment.