mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-12 15:34:00 +00:00
Hide navigation warnings on markdown textarea for site-form and user bios. Fixes #1051
This commit is contained in:
parent
fbd9adb135
commit
089aefc7af
3 changed files with 8 additions and 2 deletions
8
ui/src/components/markdown-textarea.tsx
vendored
8
ui/src/components/markdown-textarea.tsx
vendored
|
@ -25,6 +25,7 @@ interface MarkdownTextAreaProps {
|
|||
onSubmit?(msg: { val: string; formId: string }): any;
|
||||
onContentChange?(val: string): any;
|
||||
onReplyCancel?(): any;
|
||||
hideNavigationWarnings?: boolean;
|
||||
}
|
||||
|
||||
interface MarkdownTextAreaState {
|
||||
|
@ -78,7 +79,7 @@ export class MarkdownTextArea extends Component<
|
|||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
if (this.state.content) {
|
||||
if (!this.props.hideNavigationWarnings && this.state.content) {
|
||||
window.onbeforeunload = () => true;
|
||||
} else {
|
||||
window.onbeforeunload = undefined;
|
||||
|
@ -110,7 +111,10 @@ export class MarkdownTextArea extends Component<
|
|||
render() {
|
||||
return (
|
||||
<form id={this.formId} onSubmit={linkEvent(this, this.handleSubmit)}>
|
||||
<Prompt when={this.state.content} message={i18n.t('block_leaving')} />
|
||||
<Prompt
|
||||
when={!this.props.hideNavigationWarnings && this.state.content}
|
||||
message={i18n.t('block_leaving')}
|
||||
/>
|
||||
<div class="form-group row">
|
||||
<div className={`col-sm-12`}>
|
||||
<textarea
|
||||
|
|
1
ui/src/components/site-form.tsx
vendored
1
ui/src/components/site-form.tsx
vendored
|
@ -111,6 +111,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
|
|||
<MarkdownTextArea
|
||||
initialContent={this.state.siteForm.description}
|
||||
onContentChange={this.handleSiteDescriptionChange}
|
||||
hideNavigationWarnings
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
1
ui/src/components/user.tsx
vendored
1
ui/src/components/user.tsx
vendored
|
@ -593,6 +593,7 @@ export class User extends Component<any, UserState> {
|
|||
initialContent={this.state.userSettingsForm.bio}
|
||||
onContentChange={this.handleUserSettingsBioChange}
|
||||
maxLength={300}
|
||||
hideNavigationWarnings
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue