Fix Cmd-Enter not working to send toot

Fixes #1333
main
Thibaut Girka 2020-05-25 20:04:06 +02:00 committed by ThibG
parent b07c1e615b
commit c8cee24cb3
1 changed files with 5 additions and 12 deletions

View File

@ -158,19 +158,12 @@ class ComposeForm extends ImmutablePureComponent {
this.props.onSuggestionSelected(tokenStart, token, value, ['spoiler_text']); this.props.onSuggestionSelected(tokenStart, token, value, ['spoiler_text']);
} }
// When the escape key is released, we focus the UI. handleKeyDown = (e) => {
handleKeyUp = ({ key, ctrlKey, keyCode, metaKey, altKey }) => { if (e.keyCode === 13 && (e.ctrlKey || e.metaKey)) {
if (key === 'Escape') {
document.querySelector('.ui').parentElement.focus();
}
// We submit the status on control/meta + enter.
if (keyCode === 13 && (ctrlKey || metaKey)) {
this.handleSubmit(); this.handleSubmit();
} }
// Submit the status with secondary visibility on alt + enter. if (e.keyCode == 13 && e.altKey) {
if (keyCode === 13 && altKey) {
this.handleSecondarySubmit(); this.handleSecondarySubmit();
} }
} }
@ -305,7 +298,7 @@ class ComposeForm extends ImmutablePureComponent {
placeholder={intl.formatMessage(messages.spoiler_placeholder)} placeholder={intl.formatMessage(messages.spoiler_placeholder)}
value={spoilerText} value={spoilerText}
onChange={this.handleChangeSpoiler} onChange={this.handleChangeSpoiler}
onKeyUp={this.handleKeyUp} onKeyDown={this.handleKeyDown}
disabled={!spoiler} disabled={!spoiler}
ref={this.handleRefSpoilerText} ref={this.handleRefSpoilerText}
suggestions={this.props.suggestions} suggestions={this.props.suggestions}
@ -325,7 +318,7 @@ class ComposeForm extends ImmutablePureComponent {
disabled={isSubmitting} disabled={isSubmitting}
value={this.props.text} value={this.props.text}
onChange={this.handleChange} onChange={this.handleChange}
onKeyUp={this.handleKeyUp} onKeyDown={this.handleKeyDown}
suggestions={this.props.suggestions} suggestions={this.props.suggestions}
onFocus={this.handleFocus} onFocus={this.handleFocus}
onSuggestionsFetchRequested={onFetchSuggestions} onSuggestionsFetchRequested={onFetchSuggestions}