Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix submitting post from content warning field not working properly #2538

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class ComposeForm extends ImmutablePureComponent {
return !(isSubmitting || isUploading || isChangingUpload || length(fulltext) > maxChars || (!fulltext.trim().length && !anyMedia));
};

handleSubmit = (overriddenVisibility = null) => {
handleSubmit = (e, overriddenVisibility = null) => {
if (this.props.text !== this.textareaRef.current.value) {
// Something changed the text inside the textarea (e.g. browser extensions like Grammarly)
// Update the state to match the current text
Expand All @@ -136,6 +136,10 @@ class ComposeForm extends ImmutablePureComponent {
return;
}

if (e) {
e.preventDefault();
}

// Submit unless there are media with missing descriptions
if (this.props.mediaDescriptionConfirmation && this.props.media && this.props.media.some(item => !item.get('description'))) {
const firstWithoutDescription = this.props.media.find(item => !item.get('description'));
Expand All @@ -150,10 +154,8 @@ class ComposeForm extends ImmutablePureComponent {

// Handles the secondary submit button.
handleSecondarySubmit = () => {
const {
sideArm,
} = this.props;
this.handleSubmit(sideArm === 'none' ? null : sideArm);
const { sideArm } = this.props;
this.handleSubmit(null, sideArm === 'none' ? null : sideArm);
};

onSuggestionsClearRequested = () => {
Expand Down Expand Up @@ -342,7 +344,6 @@ class ComposeForm extends ImmutablePureComponent {
disabled={!this.canSubmit()}
isEditing={isEditing}
onSecondarySubmit={this.handleSecondarySubmit}
onSubmit={this.handleSubmit}
privacy={privacy}
sideArm={sideArm}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,11 @@ class Publisher extends ImmutablePureComponent {
disabled: PropTypes.bool,
intl: PropTypes.object.isRequired,
onSecondarySubmit: PropTypes.func,
onSubmit: PropTypes.func,
privacy: PropTypes.oneOf(['direct', 'private', 'unlisted', 'public']),
sideArm: PropTypes.oneOf(['none', 'direct', 'private', 'unlisted', 'public']),
isEditing: PropTypes.bool,
};

handleSubmit = () => {
this.props.onSubmit();
};

render () {
const { disabled, intl, onSecondarySubmit, privacy, sideArm, isEditing } = this.props;

Expand Down Expand Up @@ -82,9 +77,9 @@ class Publisher extends ImmutablePureComponent {
<div className='compose-form__publish-button-wrapper'>
<Button
className='primary'
type='submit'
text={publishText}
title={`${intl.formatMessage(messages.publish)}: ${intl.formatMessage(privacyNames[privacy])}`}
onClick={this.handleSubmit}
disabled={disabled}
/>
</div>
Expand Down
Loading