Fix compose form submission reloading web interface (#19762)
* Fix compose form submission reloading web interface Fix regression introduced by #19742 * Fix various compose form buttons being handled like submit buttons * Fix coding style issue * Fix missing onClick prop check
This commit is contained in:
@ -93,7 +93,7 @@ class ComposeForm extends ImmutablePureComponent {
|
||||
return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > 500 || (isOnlyWhitespace && !anyMedia));
|
||||
}
|
||||
|
||||
handleSubmit = () => {
|
||||
handleSubmit = (e) => {
|
||||
if (this.props.text !== this.autosuggestTextarea.textarea.value) {
|
||||
// Something changed the text inside the textarea (e.g. browser extensions like Grammarly)
|
||||
// Update the state to match the current text
|
||||
@ -105,6 +105,10 @@ class ComposeForm extends ImmutablePureComponent {
|
||||
}
|
||||
|
||||
this.props.onSubmit(this.context.router ? this.context.router.history : null);
|
||||
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
onSuggestionsClearRequested = () => {
|
||||
@ -217,7 +221,7 @@ class ComposeForm extends ImmutablePureComponent {
|
||||
}
|
||||
|
||||
return (
|
||||
<form className='compose-form'>
|
||||
<form className='compose-form' onSubmit={this.handleSubmit}>
|
||||
<WarningContainer />
|
||||
|
||||
<ReplyIndicatorContainer />
|
||||
@ -280,9 +284,8 @@ class ComposeForm extends ImmutablePureComponent {
|
||||
<div className='compose-form__publish'>
|
||||
<div className='compose-form__publish-button-wrapper'>
|
||||
<Button
|
||||
type="submit"
|
||||
type='submit'
|
||||
text={publishText}
|
||||
onClick={this.handleSubmit}
|
||||
disabled={!this.canSubmit()}
|
||||
block
|
||||
/>
|
||||
|
Reference in New Issue
Block a user