File tree Expand file tree Collapse file tree 1 file changed +10
-21
lines changed
Expand file tree Collapse file tree 1 file changed +10
-21
lines changed Original file line number Diff line number Diff line change @@ -69,18 +69,20 @@ import { ModalService } from "./modal.service";
6969 <p>{{text}}</p>
7070 </div>
7171 <ibm-modal-footer *ngIf="buttons.length > 0">
72- <button
73- *ngFor="let button of buttons; let i = index"
74- ibmButton="{{button.type}}"
75- (click)="buttonClicked(i)"
76- [id]="button.id">
77- {{button.text}}
78- </button>
72+ <ng-container *ngFor="let button of buttons; let i = index">
73+ <button
74+ ibmButton="{{button.type}}"
75+ (click)="buttonClicked(i)"
76+ [id]="button.id"
77+ [attr.modal-primary-focus]="button.type.indexOf('primary') !== -1 ? '' : null">
78+ {{button.text}}
79+ </button>
80+ </ng-container>
7981 </ibm-modal-footer>
8082 </ibm-modal>
8183 `
8284} )
83- export class AlertModalComponent implements AfterViewInit {
85+ export class AlertModalComponent {
8486 modalType = "default" ;
8587 headerLabel : string ;
8688 title : string ;
@@ -113,19 +115,6 @@ export class AlertModalComponent implements AfterViewInit {
113115 }
114116 }
115117
116- ngAfterViewInit ( ) : void {
117- // focus the primary button if there's one
118- if ( this . buttons && this . buttons . length > 0 ) {
119- const primaryButtonIndex = this . buttons . findIndex (
120- button => button . type . indexOf ( "primary" ) !== - 1 ) || 0 ;
121- const primaryButton = this . buttons [ primaryButtonIndex ] ;
122- const buttonNode = this . elementRef . nativeElement . querySelector ( `#${ primaryButton . id } ` ) ;
123- if ( buttonNode ) {
124- buttonNode . focus ( ) ;
125- }
126- }
127- }
128-
129118 buttonClicked ( buttonIndex ) {
130119 const button = this . buttons [ buttonIndex ] ;
131120 if ( button . click ) {
You can’t perform that action at this time.
0 commit comments