@@ -22,9 +22,10 @@ import {CrCheckboxElement} from 'chrome://resources/cr_elements/cr_checkbox/cr_c
22
22
import { CrDialogElement } from 'chrome://resources/cr_elements/cr_dialog/cr_dialog.js' ;
23
23
import { I18nMixin } from 'chrome://resources/cr_elements/i18n_mixin.js' ;
24
24
import { assert , assertNotReached } from 'chrome://resources/js/assert_ts.js' ;
25
+ import { focusWithoutInk } from 'chrome://resources/js/focus_without_ink.js' ;
25
26
import { sanitizeInnerHtml } from 'chrome://resources/js/parse_html_subset.js' ;
26
27
import { PluralStringProxyImpl } from 'chrome://resources/js/plural_string_proxy.js' ;
27
- import { PolymerElement } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' ;
28
+ import { afterNextRender , PolymerElement } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' ;
28
29
29
30
import { loadTimeData } from '../i18n_setup.js' ;
30
31
@@ -106,7 +107,10 @@ export class PasswordsImportDialogElement extends
106
107
107
108
static get properties ( ) {
108
109
return {
109
- dialogState : Number ,
110
+ dialogState : {
111
+ type : Number ,
112
+ observer : 'focusOnFirstActionableItem_' ,
113
+ } ,
110
114
111
115
importDialogStateEnum_ : {
112
116
type : Object ,
@@ -205,6 +209,24 @@ export class PasswordsImportDialogElement extends
205
209
this . dialogState = ImportDialogState . START ;
206
210
}
207
211
212
+ private focusOnFirstActionableItem_ ( ) {
213
+ afterNextRender ( this , ( ) => {
214
+ let elementToFocus = this . $ . close as HTMLElement ;
215
+ if ( this . isState_ ( ImportDialogState . CONFLICTS ) ) {
216
+ const firstCheckbox =
217
+ this . $ . conflictsList . querySelector ( 'cr-checkbox' ) as HTMLElement ;
218
+ if ( firstCheckbox ) {
219
+ elementToFocus = firstCheckbox ;
220
+ }
221
+ } else if ( ! this . shouldHideDeleteFileOption_ ( ) ) {
222
+ elementToFocus = this . $ . deleteFileOption as HTMLElement ;
223
+ } else if ( this . shouldShowStorePicker_ ( ) ) {
224
+ elementToFocus = this . $ . storePicker as HTMLElement ;
225
+ }
226
+ focusWithoutInk ( elementToFocus ) ;
227
+ } ) ;
228
+ }
229
+
208
230
private computeConflictsListClass_ ( ) : string {
209
231
return this . inProgress_ ? 'disabled-conflicts-list' : '' ;
210
232
}
@@ -376,7 +398,6 @@ export class PasswordsImportDialogElement extends
376
398
default :
377
399
assertNotReached ( ) ;
378
400
}
379
- this . $ . close . focus ( ) ;
380
401
}
381
402
382
403
private async handleSuccess_ ( ) {
@@ -418,8 +439,6 @@ export class PasswordsImportDialogElement extends
418
439
this . descriptionText_ = sanitizeInnerHtml ( descriptionText ) ;
419
440
}
420
441
this . dialogState = ImportDialogState . SUCCESS ;
421
-
422
- this . $ . close . focus ( ) ;
423
442
}
424
443
425
444
private getStoreOptionAccountText_ ( ) : string {
0 commit comments