From 3386c58d7c53131f0aa435abaf4cbb521d2f6049 Mon Sep 17 00:00:00 2001
From: David Lu <david.lu@hotmail.com>
Date: Thu, 2 Jun 2016 15:36:54 -0700
Subject: Made all settings save on enter (#3221)

---
 webapp/components/setting_item_max.jsx | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

(limited to 'webapp/components/setting_item_max.jsx')

diff --git a/webapp/components/setting_item_max.jsx b/webapp/components/setting_item_max.jsx
index 61c7ee3f8..ec496a765 100644
--- a/webapp/components/setting_item_max.jsx
+++ b/webapp/components/setting_item_max.jsx
@@ -2,10 +2,32 @@
 // See License.txt for license information.
 
 import {FormattedMessage} from 'react-intl';
+import * as Utils from 'utils/utils.jsx';
+import Constants from 'utils/constants.jsx';
 
 import React from 'react';
 
 export default class SettingItemMax extends React.Component {
+    constructor(props) {
+        super(props);
+
+        this.onKeyDown = this.onKeyDown.bind(this);
+    }
+
+    onKeyDown(e) {
+        if (e.keyCode === Constants.KeyCodes.ENTER) {
+            this.props.submit(e);
+        }
+    }
+
+    componentDidMount() {
+        document.addEventListener('keydown', this.onKeyDown);
+    }
+
+    componentWillUnmount() {
+        document.removeEventListener('keydown', this.onKeyDown);
+    }
+
     render() {
         var clientError = null;
         if (this.props.client_error) {
@@ -25,16 +47,14 @@ export default class SettingItemMax extends React.Component {
         var submit = '';
         if (this.props.submit) {
             submit = (
-                <a
+                <input
+                    type='submit'
                     className='btn btn-sm btn-primary'
                     href='#'
                     onClick={this.props.submit}
+                    value={Utils.localizeMessage('setting_item_max.save', 'Save')}
                 >
-                    <FormattedMessage
-                        id='setting_item_max.save'
-                        defaultMessage='Save'
-                    />
-                </a>
+                </input>
             );
         }
 
-- 
cgit v1.2.3-1-g7c22

