]> Untitled Git - lemmy.git/commitdiff
Hide navigation warnings on markdown textarea for site-form and user bios. Fixes...
authorDessalines <tyhou13@gmx.com>
Sun, 2 Aug 2020 14:41:17 +0000 (10:41 -0400)
committerDessalines <tyhou13@gmx.com>
Sun, 2 Aug 2020 14:41:17 +0000 (10:41 -0400)
ui/src/components/markdown-textarea.tsx
ui/src/components/site-form.tsx
ui/src/components/user.tsx

index 002d7c86ba4ddf3499bd88de7230667ce7addf67..0a7f904aac32d2ac666eb002fabc29b734ce3f5a 100644 (file)
@@ -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
index 7719e1e598429915c73d22e7dc5bb73b3e35e876..e02daabb94f27eab587986f5c4ba0c880b6ea631 100644 (file)
@@ -111,6 +111,7 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
               <MarkdownTextArea
                 initialContent={this.state.siteForm.description}
                 onContentChange={this.handleSiteDescriptionChange}
+                hideNavigationWarnings
               />
             </div>
           </div>
index 8f0b5178844ea309e6acd2381ee0b9a2e939af6f..82e5fd83526ab7e083f9ee75d06fd25a83d0f040 100644 (file)
@@ -593,6 +593,7 @@ export class User extends Component<any, UserState> {
                     initialContent={this.state.userSettingsForm.bio}
                     onContentChange={this.handleUserSettingsBioChange}
                     maxLength={300}
+                    hideNavigationWarnings
                   />
                 </div>
               </div>