Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

Fix: non-signed in users get sign in popup

Matt Roberts74a3498fcb9c
diff --git a/public/components/common/form/CommentEditor2.tsx b/public/components/common/form/CommentEditor2.tsx
index 488026177..0b0d7c568 100644
--- a/public/components/common/form/CommentEditor2.tsx
+++ b/public/components/common/form/CommentEditor2.tsx
@@ -107,6 +107,7 @@ interface CommentEditorProps2 {
initialValue: string | null
placeholder?: string
onChange?: (value: string) => void
+ onFocus?: () => void
}
const Tiptap: React.FunctionComponent<CommentEditorProps2> = (props) => {
@@ -137,6 +138,11 @@ const Tiptap: React.FunctionComponent<CommentEditorProps2> = (props) => {
extensions,
content: initialValue,
onUpdate: updated,
+ onFocus: () => {
+ if (props.onFocus) {
+ props.onFocus()
+ }
+ },
editorProps: {
attributes: {
class: "no-focus",
diff --git a/public/pages/ShowPost/components/CommentInput.tsx b/public/pages/ShowPost/components/CommentInput.tsx
index 21f4fc73e..6ed40de59 100644
--- a/public/pages/ShowPost/components/CommentInput.tsx
+++ b/public/pages/ShowPost/components/CommentInput.tsx
@@ -10,7 +10,7 @@ import { i18n } from "@lingui/core"
import { Trans } from "@lingui/react/macro"
// import { CommentEditor } from "@fider/components"
-// import { useFider } from "@fider/hooks"
+import { useFider } from "@fider/hooks"
// import Tiptap from "@fider/components/common/form/CommentEditor2"
import MemoizedTiptap from "@fider/components/common/form/CommentEditor2"
@@ -27,7 +27,7 @@ export const CommentInput = (props: CommentInputProps) => {
return cache.session.get(getCacheKey())
}
- // const fider = useFider()
+ const fider = useFider()
// const inputRef = useRef<HTMLTextAreaElement>()
// const [content, setContent] = useState<string>((fider.session.isAuthenticated && getContentFromCache()) || "")
const [isSignInModalOpen, setIsSignInModalOpen] = useState(false)
@@ -52,17 +52,11 @@ export const CommentInput = (props: CommentInputProps) => {
}
}
- // const editorFocused = () => {
- // console.log("focused")
- // if (!fider.session.isAuthenticated) {
- // setIsSignInModalOpen(true)
- // }
- // }
-
- // const commentChanged = (newContent: string) => {
- // setContent(newContent)
- // cache.session.set(getCacheKey(), newContent)
- // }
+ const editorFocused = () => {
+ if (!fider.session.isAuthenticated) {
+ setIsSignInModalOpen(true)
+ }
+ }
const hasContent = true
@@ -82,14 +76,9 @@ export const CommentInput = (props: CommentInputProps) => {
<UserName user={Fider.session.user} />
</div>
)}
- {/* <CommentEditor
- initialValue={content}
- onChange={commentChanged}
- onFocus={editorFocused}
- placeholder={i18n._("showpost.commentinput.placeholder", { message: "Leave a comment" })}
- /> */}
<MemoizedTiptap
onChange={commentChanged}
+ onFocus={editorFocused}
initialValue={getContentFromCache()}
placeholder={i18n._("showpost.commentinput.placeholder", { message: "Leave a comment" })}
/>