Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a clear, obvious way to remove hotkeys to improve UX #2883

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -107,17 +117,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