]> Untitled Git - lemmy-ui.git/commitdiff
Fix issue with empty markdown content not nulling DB. Fixes #924 (#925)
authorDessalines <dessalines@users.noreply.github.com>
Fri, 17 Feb 2023 02:10:03 +0000 (21:10 -0500)
committerGitHub <noreply@github.com>
Fri, 17 Feb 2023 02:10:03 +0000 (21:10 -0500)
* Fix issue with empty markdown content not nulling DB. Fixes #924

* Better syntax

src/shared/components/common/markdown-textarea.tsx

index 9b51a7ebffe67597e7d5030dcfed57cd95785cf7..48b90428be90797f3af42ca96640bcd4e7245003 100644 (file)
@@ -390,9 +390,9 @@ export class MarkdownTextArea extends Component<
   }
 
   contentChange() {
-    if (this.state.content) {
-      this.props.onContentChange?.(this.state.content);
-    }
+    // Coerces the undefineds to empty strings, for replacing in the DB
+    let content = this.state.content ?? "";
+    this.props.onContentChange?.(content);
   }
 
   handleContentChange(i: MarkdownTextArea, event: any) {