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:
parent
1e7ea50f4c
commit
9616f5bb22
17 changed files with 41 additions and 24 deletions
|
@ -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
|
||||
/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue