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

Unified Diff: chrome/browser/resources/settings/settings_action_menu.js

Issue 2438423002: MD Settings: Remove usage of 'autofocus' from settings-action-menu. (Closed)
Patch Set: Nit Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/webui/settings/settings_action_menu_test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/settings/settings_action_menu.js
diff --git a/chrome/browser/resources/settings/settings_action_menu.js b/chrome/browser/resources/settings/settings_action_menu.js
index e584a5552abc0f37ff8c072ca997bee5776b2dcb..740f1bdd5cc7d3829e22725b9f3bb655be9a13af 100644
--- a/chrome/browser/resources/settings/settings_action_menu.js
+++ b/chrome/browser/resources/settings/settings_action_menu.js
@@ -13,12 +13,6 @@ Polymer({
options_: null,
/**
- * Index of the currently focused item.
- * @private {number}
- */
- focusedIndex_: -1,
-
- /**
* Reference to the bound window's resize listener, such that it can be
* removed on detach.
* @private {?Function}
@@ -93,11 +87,12 @@ Polymer({
var counter = 0;
var nextOption = null;
var numOptions = this.options_.length;
+ var focusedIndex = Array.prototype.indexOf.call(
+ this.options_, this.root.activeElement);
do {
- this.focusedIndex_ =
- (numOptions + this.focusedIndex_ + step) % numOptions;
- nextOption = this.options_[this.focusedIndex_];
+ focusedIndex = (numOptions + focusedIndex + step) % numOptions;
+ nextOption = this.options_[focusedIndex];
if (nextOption.disabled || nextOption.hidden)
nextOption = null;
counter++;
@@ -119,23 +114,6 @@ Polymer({
* @param {!Element} anchorElement
*/
showAt: function(anchorElement) {
- var rect = anchorElement.getBoundingClientRect();
-
- // Ensure that the correct item is focused when the dialog is shown, by
- // setting the 'autofocus' attribute.
- this.focusedIndex_ = -1;
- var nextOption = this.getNextOption_(1);
-
- /** @suppress {checkTypes} */
- (function(options) {
- options.forEach(function(option) {
- option.removeAttribute('autofocus');
- });
- })(this.options_);
-
- if (nextOption)
- nextOption.setAttribute('autofocus', true);
-
this.onWindowResize_ = this.onWindowResize_ || function() {
if (this.open)
this.close();
@@ -144,6 +122,7 @@ Polymer({
this.showModal();
+ var rect = anchorElement.getBoundingClientRect();
if (new settings.DirectionDelegateImpl().isRtl()) {
var right = window.innerWidth - rect.left - this.offsetWidth;
this.style.right = right + 'px';
« no previous file with comments | « no previous file | chrome/test/data/webui/settings/settings_action_menu_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698