mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-06 18:01:05 +00:00
fix: Don't submit post when pressing Enter in CW field (#35445)
This commit is contained in:
parent
4de5cbd6f5
commit
ee21f72211
|
@ -92,13 +92,29 @@ class ComposeForm extends ImmutablePureComponent {
|
||||||
this.props.onChange(e.target.value);
|
this.props.onChange(e.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
handleKeyDown = (e) => {
|
blurOnEscape = (e) => {
|
||||||
if (e.key.toLowerCase() === 'enter' && (e.ctrlKey || e.metaKey)) {
|
|
||||||
this.handleSubmit();
|
|
||||||
}
|
|
||||||
if (['esc', 'escape'].includes(e.key.toLowerCase())) {
|
if (['esc', 'escape'].includes(e.key.toLowerCase())) {
|
||||||
this.textareaRef.current?.blur();
|
e.target.blur();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleKeyDownPost = (e) => {
|
||||||
|
if (e.key.toLowerCase() === 'enter' && (e.ctrlKey || e.metaKey)) {
|
||||||
|
this.handleSubmit();
|
||||||
|
}
|
||||||
|
this.blurOnEscape(e);
|
||||||
|
};
|
||||||
|
|
||||||
|
handleKeyDownSpoiler = (e) => {
|
||||||
|
if (e.key.toLowerCase() === 'enter') {
|
||||||
|
if (e.ctrlKey || e.metaKey) {
|
||||||
|
this.handleSubmit();
|
||||||
|
} else {
|
||||||
|
e.preventDefault();
|
||||||
|
this.textareaRef.current?.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.blurOnEscape(e);
|
||||||
};
|
};
|
||||||
|
|
||||||
getFulltextForCharacterCounting = () => {
|
getFulltextForCharacterCounting = () => {
|
||||||
|
@ -251,7 +267,7 @@ class ComposeForm extends ImmutablePureComponent {
|
||||||
value={this.props.spoilerText}
|
value={this.props.spoilerText}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
onChange={this.handleChangeSpoilerText}
|
onChange={this.handleChangeSpoilerText}
|
||||||
onKeyDown={this.handleKeyDown}
|
onKeyDown={this.handleKeyDownSpoiler}
|
||||||
ref={this.setSpoilerText}
|
ref={this.setSpoilerText}
|
||||||
suggestions={this.props.suggestions}
|
suggestions={this.props.suggestions}
|
||||||
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
|
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
|
||||||
|
@ -276,7 +292,7 @@ class ComposeForm extends ImmutablePureComponent {
|
||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
suggestions={this.props.suggestions}
|
suggestions={this.props.suggestions}
|
||||||
onFocus={this.handleFocus}
|
onFocus={this.handleFocus}
|
||||||
onKeyDown={this.handleKeyDown}
|
onKeyDown={this.handleKeyDownPost}
|
||||||
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
|
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
|
||||||
onSuggestionsClearRequested={this.onSuggestionsClearRequested}
|
onSuggestionsClearRequested={this.onSuggestionsClearRequested}
|
||||||
onSuggestionSelected={this.onSuggestionSelected}
|
onSuggestionSelected={this.onSuggestionSelected}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user