Closed alanchan-dev closed 11 months ago
Hey @alanchan-dev,
Author name and avatar should be auto populated from your GitHub user details on new posts, so it's never empty. How are you able to have an empty author on new documents?
Author fields are not marked as "required" in our validations.
I've tested the behaviour of deleting the auto-populated author and I'm able to save the post.
I've also opened a post that had empty author fields and was still able to save it.
I'm really curious about how this error is happening for you.
Does your network tab make a request to http://localhost:3000/api/outstatic/user
when you try to create a new post?
Does that request succeeds and returns your name and image?
@avitorio I realized that because I did not set a name for my Github, that's why it doesn't auto populate the field. When it's initially not populated the Save just won't go through. Not sure why it's not required but not able to Save if initially it's empty.
Interesting! Thanks for digging it further. Maybe the value comes as undefined or null... and the filed expects a string. I'll check it out.
Hey @alanchan-dev , do you want to give at stab at fixing this? It would be quite a trivial check, just seeing what kind of response you are getting and adding an if statement to replace the null or undefined value with an empty string. Maybe setting the Author name as an empty string from the beginning.
This looks like a cool first issue to work on and it would get you familarized with the codebase. I'm here to help!
@avitorio Happy to take this on if that's okay with you
@kndwin that would be awesome! I'm here to help.
This has been fixed by: https://github.com/avitorio/outstatic/pull/169 It will be merged soon. Thank you @kndwin !
Provide environment information
"dependencies": { "@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-dropdown-menu": "^2.0.6", "@radix-ui/react-navigation-menu": "^1.1.4", "@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-tabs": "^1.0.4", "@types/node": "20.9.0", "@types/react": "18.2.37", "@types/react-dom": "18.2.15", "autoprefixer": "10.4.16", "class-variance-authority": "^0.7.0", "clsx": "^2.0.0", "cmdk": "^0.2.0", "eslint": "8.53.0", "eslint-config-next": "^14.0.2", "framer-motion": "^10.16.4", "gray-matter": "^4.0.3", "lucide-react": "^0.292.0", "next": "^14.0.2", "next-themes": "^0.2.1", "outstatic": "^1.0.3", "postcss": "^8.4.31", "react": "^18.2.0", "react-code-blocks": "^0.1.4", "react-dom": "^18.2.0", "react-markdown": "^9.0.0", "remark": "^15.0.1", "remark-gfm": "^4.0.0", "styled-components": "6.1.1", "tailwind-merge": "^2.0.0", "tailwindcss": "3.3.5", "tailwindcss-animate": "^1.0.7", "typescript": "5.2.2" }
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
When creating a post, Title and Content are working as intended (They must be filled to proceed save), however Author name field is not having prompt that it is required. One thing to note is it can be bypassed by filling in and clearing it then can proceed to save.
Expected Behavior
Either of these depending on which was the intended way initially:
Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster
N/A
To Reproduce
Create new post -> fill in Title and Contents -> Type something into Author name field but remove them using backspace -> Click Save -> It will save the post
Create new post -> fill in Title and Contents ( leave Author name empty) -> Click Save -> No prompt is shown indicating Author name is required