Skip to content

Commit

Permalink
Add a clear, obvious way to remove hotkeys to improve UX (#2867)
Browse files Browse the repository at this point in the history
  • Loading branch information
zbrcz committed Dec 16, 2017
1 parent 23a4bb8 commit a80944a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/renderer/ui/components/settings/HotkeyInput.js
@@ -1,6 +1,6 @@
import _ from 'lodash';
import React, { Component, PropTypes } from 'react';
import TextField from 'material-ui/TextField';
import { FlatButton, TextField } from 'material-ui';

import { requireSettings } from '../generic/SettingsProvider';
import { ACCELERATOR_KEYS, MODIFIER_KEYS, ACTION_KEYS } from '../../utils/constants';
Expand All @@ -10,6 +10,16 @@ const styles = {
width: '50%',
float: 'left',
padding: '4px 6px',
position: 'relative',
},
removeHotkeyButton: {
backgroundColor: 'transparent',
border: 'none',
cursor: 'pointer',
position: 'absolute',
minWidth: 0,
right: 10,
top: 35,
},
};

Expand Down Expand Up @@ -106,17 +116,23 @@ class HotkeyInput extends Component {
}

render() {
let removeHotkeyButton;
const hotkey = this.props.hotkeys[this.props.hotkeyAction];
if (hotkey) {
removeHotkeyButton = <FlatButton style={styles.removeHotkeyButton} onClick={this._reset}></FlatButton>;
}
return (
<div style={styles.inputContainer}>
<TextField
hintText={TranslationProvider.query('settings-option-hotkey-hint')}
floatingLabelText={this.props.label}
floatingLabelFixed
value={this.props.hotkeys[this.props.hotkeyAction] || TranslationProvider.query('settings-option-hotkey-not-set')}
value={hotkey || TranslationProvider.query('settings-option-hotkey-not-set')}
onKeyDown={this._handleKeyDown}
onKeyUp={this._handleKeyUp}
fullWidth
/>
{removeHotkeyButton}
</div>
);
}
Expand Down

0 comments on commit a80944a

Please sign in to comment.