@@ -17,24 +17,24 @@ function addButtonsToAlertController(alertController: UIAlertController, options
1717 alertController . addAction (
1818 UIAlertAction . actionWithTitleStyleHandler ( options . cancelButtonText , UIAlertActionStyle . Default , ( ) => {
1919 raiseCallback ( callback , false ) ;
20- } )
20+ } ) ,
2121 ) ;
2222 }
2323
2424 if ( isString ( options . neutralButtonText ) ) {
2525 alertController . addAction (
2626 UIAlertAction . actionWithTitleStyleHandler ( options . neutralButtonText , UIAlertActionStyle . Default , ( ) => {
2727 raiseCallback ( callback , undefined ) ;
28- } )
28+ } ) ,
2929 ) ;
3030 }
3131
3232 if ( isString ( options . okButtonText ) ) {
33- alertController . addAction (
34- UIAlertAction . actionWithTitleStyleHandler ( options . okButtonText , UIAlertActionStyle . Default , ( ) => {
35- raiseCallback ( callback , true ) ;
36- } )
37- ) ;
33+ const action = UIAlertAction . actionWithTitleStyleHandler ( options . okButtonText , UIAlertActionStyle . Default , ( ) => {
34+ raiseCallback ( callback , true ) ;
35+ } ) ;
36+ alertController . addAction ( action ) ;
37+ alertController . preferredAction = action ; // Allows using keyboard enter/return to confirm the dialog
3838 }
3939}
4040
@@ -91,7 +91,7 @@ export function alert(arg: any): Promise<void> {
9191 title : DialogStrings . ALERT ,
9292 okButtonText : DialogStrings . OK ,
9393 message : arg + '' ,
94- }
94+ }
9595 : arg ;
9696 const alertController = UIAlertController . alertControllerWithTitleMessagePreferredStyle ( options . title , options . message , UIAlertControllerStyle . Alert ) ;
9797
@@ -115,7 +115,7 @@ export function confirm(arg: any): Promise<boolean> {
115115 okButtonText : DialogStrings . OK ,
116116 cancelButtonText : DialogStrings . CANCEL ,
117117 message : arg + '' ,
118- }
118+ }
119119 : arg ;
120120 const alertController = UIAlertController . alertControllerWithTitleMessagePreferredStyle ( options . title , options . message , UIAlertControllerStyle . Alert ) ;
121121
@@ -301,7 +301,7 @@ export function action(...args): Promise<string> {
301301 alertController . addAction (
302302 UIAlertAction . actionWithTitleStyleHandler ( action , dialogType , ( arg : UIAlertAction ) => {
303303 resolve ( arg . title ) ;
304- } )
304+ } ) ,
305305 ) ;
306306 }
307307 }
@@ -311,7 +311,7 @@ export function action(...args): Promise<string> {
311311 alertController . addAction (
312312 UIAlertAction . actionWithTitleStyleHandler ( options . cancelButtonText , UIAlertActionStyle . Cancel , ( arg : UIAlertAction ) => {
313313 resolve ( arg . title ) ;
314- } )
314+ } ) ,
315315 ) ;
316316 }
317317
0 commit comments