| Index: chrome/browser/resources/settings/controls/settings_input.js
|
| diff --git a/chrome/browser/resources/settings/controls/settings_input.js b/chrome/browser/resources/settings/controls/settings_input.js
|
| index ea075476fe84ae7cda2a7d7c44a5a93eb1072565..83ca1d6860c56b5cf199fe037deac71d235a7fef 100644
|
| --- a/chrome/browser/resources/settings/controls/settings_input.js
|
| +++ b/chrome/browser/resources/settings/controls/settings_input.js
|
| @@ -18,9 +18,7 @@ Polymer({
|
| * @type {!chrome.settingsPrivate.PrefObject|undefined}
|
| * @override
|
| */
|
| - pref: {
|
| - observer: 'prefChanged_'
|
| - },
|
| + pref: {observer: 'prefChanged_'},
|
|
|
| /* The current value of the input, reflected to/from |pref|. */
|
| value: {
|
| @@ -30,24 +28,20 @@ Polymer({
|
| },
|
|
|
| /* Set to true to disable editing the input. */
|
| - disabled: {
|
| - type: Boolean,
|
| - value: false,
|
| - reflectToAttribute: true
|
| - },
|
| + disabled: {type: Boolean, value: false, reflectToAttribute: true},
|
|
|
| canTab: Boolean,
|
|
|
| /* Properties for paper-input. This is not strictly necessary.
|
| * Though it does define the types for the closure compiler. */
|
| - errorMessage: { type: String },
|
| - label: { type: String },
|
| - noLabelFloat: { type: Boolean, value: false },
|
| - pattern: { type: String },
|
| - readonly: { type: Boolean, value: false },
|
| - required: { type: Boolean, value: false },
|
| - stopKeyboardEventPropagation: { type: Boolean, value: false },
|
| - type: { type: String },
|
| + errorMessage: {type: String},
|
| + label: {type: String},
|
| + noLabelFloat: {type: Boolean, value: false},
|
| + pattern: {type: String},
|
| + readonly: {type: Boolean, value: false},
|
| + required: {type: Boolean, value: false},
|
| + stopKeyboardEventPropagation: {type: Boolean, value: false},
|
| + type: {type: String},
|
| },
|
|
|
| /**
|
| @@ -103,10 +97,14 @@ Polymer({
|
| if (!this.pref)
|
| return;
|
|
|
| + if (this.$.input.inputElement.invalid) {
|
| + this.resetValue_();
|
| + return;
|
| + }
|
| +
|
| if (this.pref.type == chrome.settingsPrivate.PrefType.NUMBER) {
|
| if (!this.value) {
|
| - // Ignore empty input field and restore value.
|
| - this.value = this.pref.value.toString();
|
| + this.resetValue_();
|
| return;
|
| }
|
| var n = parseInt(this.value, 10);
|
| @@ -122,17 +120,29 @@ Polymer({
|
| }
|
| },
|
|
|
| + /** @private */
|
| + resetValue_: function() {
|
| + this.$.input.inputElement.invalid = false;
|
| + this.setInputValueFromPref_();
|
| + this.$.input.blur();
|
| + },
|
| +
|
| /**
|
| * Handler for profile name keydowns.
|
| * @param {!Event} event
|
| * @private
|
| */
|
| onKeydown_: function(event) {
|
| + /* If pressed enter when input is invalid, do not trigger on-change */
|
| + if (event.key == 'Enter' && this.$.input.inputElement.invalid) {
|
| + event.preventDefault();
|
| + return;
|
| + }
|
| +
|
| if (event.key != 'Escape')
|
| return;
|
|
|
| - this.setInputValueFromPref_();
|
| - this.$.input.blur();
|
| + this.resetValue_();
|
| },
|
|
|
| /**
|
|
|