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

Unified Diff: ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js

Issue 2803543003: WebUI: fix cr-action-menu keyboard off-by-one issue (Closed)
Patch Set: add test Created 3 years, 8 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
Index: ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js
diff --git a/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js b/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js
index a8e065db682e77c39cd3f2a1cb2e694e684c8ea7..2a75c307095dd2ee3264e614c2f0075af304a878 100644
--- a/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js
+++ b/ui/webui/resources/cr_elements/cr_action_menu/cr_action_menu.js
@@ -124,6 +124,10 @@ Polymer({
var focusedIndex =
Array.prototype.indexOf.call(this.options_, this.root.activeElement);
+ // Avoid off-by-one when nothing is focused and up is pressed.
dpapad 2017/04/05 21:49:13 Nit (optional): Perhaps just rephrase to // Handle
scottchen 2017/04/06 17:54:02 Done.
+ if (focusedIndex === -1 && step === -1)
+ focusedIndex = 0;
+
do {
focusedIndex = (numOptions + focusedIndex + step) % numOptions;
nextOption = this.options_[focusedIndex];

Powered by Google App Engine
This is Rietveld 408576698