summaryrefslogtreecommitdiffstats
path: root/webapp/components/setting_item_max.jsx
diff options
context:
space:
mode:
authorDavid Lu <david.lu@hotmail.com>2016-06-02 15:36:54 -0700
committerenahum <nahumhbl@gmail.com>2016-06-02 19:36:54 -0300
commit3386c58d7c53131f0aa435abaf4cbb521d2f6049 (patch)
tree003b236aab1546682998ed7d6c4a7dc618c82790 /webapp/components/setting_item_max.jsx
parent159953050a9c4fb700bbde79042ead4843b0bea5 (diff)
downloadchat-3386c58d7c53131f0aa435abaf4cbb521d2f6049.tar.gz
chat-3386c58d7c53131f0aa435abaf4cbb521d2f6049.tar.bz2
chat-3386c58d7c53131f0aa435abaf4cbb521d2f6049.zip
Made all settings save on enter (#3221)
Diffstat (limited to 'webapp/components/setting_item_max.jsx')
-rw-r--r--webapp/components/setting_item_max.jsx32
1 files changed, 26 insertions, 6 deletions
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>
);
}