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

Unified Diff: chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js

Issue 2119713003: Pin keyboard use enter to submit when focus is not on a button. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 4 years, 6 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: chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js
diff --git a/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js b/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js
index dfc111d4c5fcd7c32df8aa1e7a95762d0894bfbb..a4204294e8d91c277bd003b3d7195f2304d7ecd6 100644
--- a/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js
+++ b/chrome/browser/resources/chromeos/quick_unlock/pin_keyboard.js
@@ -35,15 +35,42 @@ Polymer({
}
},
+ // Flag to check focus on next focus.
+ checkFocus_: false,
+ // The current focused element.
+ focusedElement_: undefined,
+
/** Transfers focus to the input element. */
focus: function() {
this.$$('#pin-input').focus();
+ this.focusedElement_ = document.activeElement;
+ },
+
+ /** Called when a pin keyboard button has focus. */
+ onButtonFocus_: function(event, detail) {
+ // If the button has been tabbed here it is the current element with focus.
+ if (this.checkFocus_) {
+ this.focusedElement_ = document.activeElement;
+ this.checkFocus_ = false;
+ }
+ },
+
+ /** Called when a pin keyboard has a key pressed. */
+ onButtonKeyDown_: function(event, detail) {
+ // Only if tab has been pressed do we want change the focus.
+ if (event.keyCode == 9)
+ this.checkFocus_ = true;
},
/** Called when a keypad number has been tapped. */
onNumberTap_: function(event, detail) {
var numberValue = event.target.getAttribute('value');
this.value += numberValue;
+
+ // If the tabbed element is clicked we want to keep the focus, otherwise
+ // transfer focus to the input.
+ if (this.focusedElement_ != event.target)
+ this.focus();
},
/** Fires a submit event with the current PIN value. */

Powered by Google App Engine
This is Rietveld 408576698