mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-14 16:28:59 +00:00
[Glitch] fix: Don't submit post when pressing Enter in CW field
Port ee21f72211 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -100,7 +100,13 @@ class ComposeForm extends ImmutablePureComponent {
|
||||
this.props.onChange(e.target.value);
|
||||
};
|
||||
|
||||
handleKeyDown = (e) => {
|
||||
blurOnEscape = (e) => {
|
||||
if (['esc', 'escape'].includes(e.key.toLowerCase())) {
|
||||
e.target.blur();
|
||||
}
|
||||
}
|
||||
|
||||
handleKeyDownPost = (e) => {
|
||||
if (e.key.toLowerCase() === 'enter' && (e.ctrlKey || e.metaKey)) {
|
||||
this.handleSubmit(e);
|
||||
}
|
||||
@@ -109,11 +115,23 @@ class ComposeForm extends ImmutablePureComponent {
|
||||
this.handleSecondarySubmit(e);
|
||||
}
|
||||
|
||||
if (['esc', 'escape'].includes(e.key.toLowerCase())) {
|
||||
this.textareaRef.current?.blur();
|
||||
}
|
||||
this.blurOnEscape(e);
|
||||
};
|
||||
|
||||
handleKeyDownSpoiler = (e) => {
|
||||
if (e.key.toLowerCase() === 'enter') {
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
this.handleSubmit();
|
||||
} else if (e.altKey) {
|
||||
this.handleSecondarySubmit(e);
|
||||
} else {
|
||||
e.preventDefault();
|
||||
this.textareaRef.current?.focus();
|
||||
}
|
||||
}
|
||||
this.blurOnEscape(e);
|
||||
}
|
||||
|
||||
getFulltextForCharacterCounting = () => {
|
||||
return [this.props.spoiler? this.props.spoilerText: '', countableText(this.props.text)].join('');
|
||||
};
|
||||
@@ -269,7 +287,7 @@ class ComposeForm extends ImmutablePureComponent {
|
||||
value={this.props.spoilerText}
|
||||
disabled={isSubmitting}
|
||||
onChange={this.handleChangeSpoilerText}
|
||||
onKeyDown={this.handleKeyDown}
|
||||
onKeyDown={this.handleKeyDownSpoiler}
|
||||
ref={this.setSpoilerText}
|
||||
suggestions={this.props.suggestions}
|
||||
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
|
||||
@@ -294,7 +312,7 @@ class ComposeForm extends ImmutablePureComponent {
|
||||
onChange={this.handleChange}
|
||||
suggestions={this.props.suggestions}
|
||||
onFocus={this.handleFocus}
|
||||
onKeyDown={this.handleKeyDown}
|
||||
onKeyDown={this.handleKeyDownPost}
|
||||
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested}
|
||||
onSuggestionsClearRequested={this.onSuggestionsClearRequested}
|
||||
onSuggestionSelected={this.onSuggestionSelected}
|
||||
|
||||
Reference in New Issue
Block a user