From 76a656bc5b77e329d66551d2d2c7660dd3c469da Mon Sep 17 00:00:00 2001
From: "maxime.io" <maxime.de.visscher@gmail.com>
Date: Mon, 7 Aug 2023 14:39:44 +0200
Subject: [PATCH] Fix suggested title "&nbsp;" spaces (#2037)

* Fix imported title &nbsp spaces

* Update src/shared/components/post/post-form.tsx

Co-authored-by: SleeplessOne1917 <abias1122@gmail.com>

* Fix lint issue

---------

Co-authored-by: SleeplessOne1917 <abias1122@gmail.com>
---
 src/shared/components/post/post-form.tsx | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/shared/components/post/post-form.tsx b/src/shared/components/post/post-form.tsx
index 6c88628..7b37926 100644
--- a/src/shared/components/post/post-form.tsx
+++ b/src/shared/components/post/post-form.tsx
@@ -582,8 +582,10 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
       case "loading":
         return <Spinner />;
       case "success": {
-        const suggestedTitle = this.state.metadataRes.data.metadata.title;
-
+        // Clean up the title of any extra whitespace and replace &nbsp; with a space
+        const suggestedTitle = this.state.metadataRes.data.metadata.title
+          ?.trim()
+          .replace(/\s+/g, " ");
         return (
           suggestedTitle && (
             <button
-- 
2.44.1