| Index: chrome/browser/resources/chromeos/quick_unlock/md_pin_keyboard.js
|
| diff --git a/chrome/browser/resources/chromeos/quick_unlock/md_pin_keyboard.js b/chrome/browser/resources/chromeos/quick_unlock/md_pin_keyboard.js
|
| index d3740c76c39c4fdc94efc0eeaef7bc46903561c7..7d6c305ced2e93b6ed1fe310487e0719b9a394ba 100644
|
| --- a/chrome/browser/resources/chromeos/quick_unlock/md_pin_keyboard.js
|
| +++ b/chrome/browser/resources/chromeos/quick_unlock/md_pin_keyboard.js
|
| @@ -175,9 +175,21 @@ Polymer({
|
| this.passwordElement.selectionEnd = end;
|
| },
|
|
|
| - /** Transfers focus to the input element. */
|
| - focus: function() {
|
| - this.passwordElement.focus();
|
| + /**
|
| + * Transfers focus to the input element. This should not bring up the virtual
|
| + * keyboard, if it is enabled. After focus, moves the caret to the correct
|
| + * location if specified.
|
| + * @param {number=} opt_selectionStart
|
| + * @param {number=} opt_selectionEnd
|
| + */
|
| + focus: function(opt_selectionStart, opt_selectionEnd) {
|
| + setTimeout(function() {
|
| + this.passwordElement.focus();
|
| + if (opt_selectionStart)
|
| + this.selectionStart_ = opt_selectionStart;
|
| + if (opt_selectionEnd)
|
| + this.selectionEnd_ = opt_selectionEnd;
|
| + }.bind(this), 0);
|
| },
|
|
|
| /**
|
| @@ -193,15 +205,13 @@ Polymer({
|
| var selectionStart = this.selectionStart_;
|
| this.value = this.value.substring(0, this.selectionStart_) + numberValue +
|
| this.value.substring(this.selectionEnd_);
|
| - this.selectionStart_ = selectionStart + 1;
|
| - this.selectionEnd_ = this.selectionStart_;
|
|
|
| // If a number button is clicked, we do not want to switch focus to the
|
| // button, therefore we transfer focus back to the input, but if a number
|
| // button is tabbed into, it should keep focus, so users can use tab and
|
| // spacebar/return to enter their PIN.
|
| if (!event.target.receivedFocusFromKeyboard)
|
| - this.focus();
|
| + this.focus(selectionStart + 1, selectionStart + 1);
|
| event.preventDefault();
|
| },
|
|
|
| @@ -258,9 +268,9 @@ Polymer({
|
| this.onPinClear_.bind(this), REPEAT_BACKSPACE_DELAY_MS);
|
| }.bind(this), INITIAL_BACKSPACE_DELAY_MS);
|
|
|
| - if (!event.target.receivedFocusFromKeyboard)
|
| - this.focus();
|
| - event.preventDefault();
|
| + // TODO(sammiequon): Investigate how we can keep the caret shown when
|
| + // holding the backspace button down. (Adding a this.focus(); call here will
|
| + // bring the virtual keyboard up when it is enabled.)
|
| },
|
|
|
| /**
|
|
|