Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: chrome/browser/resources/settings/languages_page/add_languages_dialog.js

Issue 2523403003: Language settings: fix focus issues (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 'settings-add-languages-dialog' is a dialog for enabling 6 * @fileoverview 'settings-add-languages-dialog' is a dialog for enabling
7 * languages. 7 * languages.
8 */ 8 */
9 Polymer({ 9 Polymer({
10 is: 'settings-add-languages-dialog', 10 is: 'settings-add-languages-dialog',
(...skipping 16 matching lines...) Expand all
27 27
28 /** @private */ 28 /** @private */
29 disableActionButton_: { 29 disableActionButton_: {
30 type: Boolean, 30 type: Boolean,
31 value: true, 31 value: true,
32 }, 32 },
33 }, 33 },
34 34
35 attached: function() { 35 attached: function() {
36 this.$.dialog.showModal(); 36 this.$.dialog.showModal();
37 // Fire iron-resize after the list initially displays to prevent flickering. 37 // To prevent flashing the Cancel button focus, "focus" the disabled Add
38 setTimeout(function() { 38 // button, so nothing has a focus state until the afterShown_ call.
39 this.$$('iron-list').fire('iron-resize'); 39 this.$$('.action-button').focus();
stevenjb 2016/11/28 17:49:16 This seems klugey. Can we just blur the cancel but
michaelpg 2016/12/01 23:19:13 Done. Thought I had tried that!
40 }.bind(this)); 40 setTimeout(this.afterShown_.bind(this));
41 }, 41 },
42 42
43 /** 43 /**
44 * Re-initializes the dialog after it is shown.
45 * @private
46 */
47 afterShown_: function() {
48 // Only fire iron-list after the list displayed to prevent flickering.
stevenjb 2016/11/28 17:49:16 'fire iron-resize' ?
michaelpg 2016/12/01 23:19:13 Done.
49 this.$$('iron-list').fire('iron-resize');
50
51 // Focus the top checkbox, assuming there are languages left to enable.
52 var firstCheckbox = this.$$('iron-list paper-checkbox');
53 if (firstCheckbox)
54 firstCheckbox.focus();
55 },
56
57 /**
44 * Returns the supported languages that are not yet enabled, based on 58 * Returns the supported languages that are not yet enabled, based on
45 * the LanguageHelper's enabled languages list. 59 * the LanguageHelper's enabled languages list.
46 * @param {!Array<!chrome.languageSettingsPrivate.Language>} 60 * @param {!Array<!chrome.languageSettingsPrivate.Language>}
47 * supportedLanguages 61 * supportedLanguages
48 * @param {!Object} enabledLanguagesChange Polymer change record for 62 * @param {!Object} enabledLanguagesChange Polymer change record for
49 * |enabledLanguages|. 63 * |enabledLanguages|.
50 * @return {!Array<!chrome.languageSettingsPrivate.Language>} 64 * @return {!Array<!chrome.languageSettingsPrivate.Language>}
51 * @private 65 * @private
52 */ 66 */
53 getAvailableLanguages_: function(supportedLanguages, enabledLanguagesChange) { 67 getAvailableLanguages_: function(supportedLanguages, enabledLanguagesChange) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 /** 107 /**
94 * Enables the checked languages. 108 * Enables the checked languages.
95 * @private 109 * @private
96 */ 110 */
97 onActionButtonTap_: function() { 111 onActionButtonTap_: function() {
98 this.$.dialog.close(); 112 this.$.dialog.close();
99 for (var languageCode of this.languagesToAdd_) 113 for (var languageCode of this.languagesToAdd_)
100 this.languageHelper.enableLanguage(languageCode); 114 this.languageHelper.enableLanguage(languageCode);
101 }, 115 },
102 }); 116 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698