Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR updates the “create post/quote” flow in the dashboard UI and adjusts the SubmitPost experience, including group selection data and form layout, to address create-post issues and make the “create” button open an in-place dialog.
Changes:
- Added
MOCK_GROUPSand switchedSubmitPostto use mock groups instead of querying groups from the API. - Refactored
SubmitPostFormlayout (title/content/citation URL) and removed URL-paste parsing behavior. - Updated multiple create-entry points (Sidebar, MainNavBar, DashboardLayout, Explore) to open the SubmitPost dialog and hide the dialog close button.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| quotevote-frontend/src/lib/mock-data.ts | Introduces MOCK_GROUPS mock group list used by SubmitPost. |
| quotevote-frontend/src/components/SubmitPost/SubmitPostForm.tsx | Refactors form UI/validation flow and citation URL handling. |
| quotevote-frontend/src/components/SubmitPost/SubmitPost.tsx | Replaces GROUPS_QUERY usage with MOCK_GROUPS. |
| quotevote-frontend/src/components/Sidebar/Sidebar.tsx | Simplifies dialog content and hides default close button. |
| quotevote-frontend/src/components/Navbars/MainNavBar.tsx | Hides dialog close button for create dialog. |
| quotevote-frontend/src/app/dashboard/layout.tsx | Replaces “Create” link with button that opens a dialog containing SubmitPost. |
| quotevote-frontend/src/app/dashboard/explore/ExploreContent.tsx | Replaces “Write” link with button that opens a dialog containing SubmitPost. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -34,20 +17,9 @@ export function SubmitPost({ setOpen }: SubmitPostProps) { | |||
| ) | |||
| } | |||
|
|
|||
| const groupsOptions: Group[] = | |||
| ((data as { groups?: Group[] })?.groups?.filter((group: Group) => { | |||
| const isUserAllowed = group.allowedUserIds?.find( | |||
| (id) => id === userId | |||
| ) | |||
| return ( | |||
| group.privacy === 'public' || | |||
| (group.privacy === 'private' && isUserAllowed) | |||
| ) | |||
| }) || []) as Group[] | |||
|
|
|||
| return ( | |||
| <SubmitPostForm | |||
| options={groupsOptions} | |||
| options={MOCK_GROUPS} | |||
| user={{ _id: String(userId), ...user } as { _id: string; [key: string]: unknown }} | |||
There was a problem hiding this comment.
SubmitPost now always passes MOCK_GROUPS instead of fetching real groups. This bypasses privacy/allowed-user filtering and can submit posts with group IDs that don’t exist in the backend (especially if mocks are only for fallback), which is likely to break addPost or mis-associate posts. Consider restoring GROUPS_QUERY (with proper loading/error states) and only falling back to mocks when the query returns an empty list.
| {errors.text && ( | ||
| <div | ||
| ref={errorAlertRef} | ||
| className="flex items-center gap-2 bg-red-50 border border-red-400 rounded p-3 mt-2" | ||
| > | ||
| <AlertTriangle className="h-5 w-5 text-red-500 shrink-0" /> | ||
| <p className="text-sm text-red-600 font-medium">{errors.text.message}</p> | ||
| </div> |
There was a problem hiding this comment.
The inline error block for errors.text is visually prominent but isn’t announced to assistive tech. Consider adding role="alert" (and/or aria-live="polite") to the error container so screen readers get notified when validation errors appear.
| {/* Create Quote Dialog */} | ||
| <Dialog open={openCreateQuote} onOpenChange={setOpenCreateQuote}> | ||
| <DialogContent className="max-w-full h-full sm:max-w-full"> | ||
| <DialogHeader> | ||
| <DialogTitle className="sr-only">Create Quote</DialogTitle> | ||
| <DialogDescription> | ||
| Create a new quote post to share with the community | ||
| </DialogDescription> | ||
| </DialogHeader> | ||
| <DialogContent className="max-w-md p-0" showCloseButton={false}> | ||
| <SubmitPost setOpen={setOpenCreateQuote} /> | ||
| </DialogContent> |
There was a problem hiding this comment.
This dialog no longer includes a DialogTitle/DialogDescription. Radix Dialog expects an accessible name for screen readers; omitting a title typically triggers warnings and makes the dialog harder to navigate with assistive tech. Add a DialogTitle (can be sr-only) inside DialogContent (and optionally a description), even if the visible header is handled by SubmitPostForm.
| <Dialog open={submitDialogOpen} onOpenChange={setSubmitDialogOpen}> | ||
| <DialogContent className={isMediumScreen ? 'max-w-md' : 'max-w-full h-full'}> | ||
| <DialogContent className={isMediumScreen ? 'max-w-md' : 'max-w-full h-full'} showCloseButton={false}> | ||
| <SubmitPost setOpen={setSubmitDialogOpen} /> | ||
| </DialogContent> |
There was a problem hiding this comment.
DialogContent is rendered without a DialogTitle/DialogDescription. For Radix Dialog accessibility, the content should include an accessible title (often DialogTitle with sr-only) so screen readers can announce what opened. Consider adding a hidden DialogTitle like “Create Quote” inside the dialog.
| _id: oid('g1a2b3c4d5e6f7a8b9c0d1e2'), | ||
| title: 'General', | ||
| description: 'General discussion for all topics', | ||
| privacy: 'public', | ||
| allowedUserIds: [], | ||
| }, | ||
| { | ||
| _id: oid('g2b3c4d5e6f7a8b9c0d1e2f3'), | ||
| title: 'Technology', | ||
| description: 'Tech news, software, and innovation', | ||
| privacy: 'public', | ||
| allowedUserIds: [], | ||
| }, | ||
| { | ||
| _id: oid('g3c4d5e6f7a8b9c0d1e2f3a4'), | ||
| title: 'Philosophy', | ||
| description: 'Ideas, ethics, and ways of thinking', | ||
| privacy: 'public', | ||
| allowedUserIds: [], | ||
| }, | ||
| { | ||
| _id: oid('g4d5e6f7a8b9c0d1e2f3a4b5'), | ||
| title: 'Politics & Society', | ||
| description: 'Civic discourse and social issues', | ||
| privacy: 'public', | ||
| allowedUserIds: [], | ||
| }, | ||
| { | ||
| _id: oid('g5e6f7a8b9c0d1e2f3a4b5c6'), | ||
| title: 'Science', | ||
| description: 'Research, discoveries, and evidence-based discussion', | ||
| privacy: 'public', | ||
| allowedUserIds: [], | ||
| }, | ||
| { | ||
| _id: oid('g6f7a8b9c0d1e2f3a4b5c6d7'), |
There was a problem hiding this comment.
MOCK_GROUPS uses _id: oid('g1a2...') style seeds that contain non-hex characters (e.g. g), so the resulting strings are not valid MongoDB ObjectIds. If these IDs get sent as groupId in addPost, the backend/mongoose ObjectId casting will throw. Use 24-char hex-only strings (0-9a-f) or generate deterministic hex (e.g. from a hash) for mock group IDs.
| _id: oid('g1a2b3c4d5e6f7a8b9c0d1e2'), | |
| title: 'General', | |
| description: 'General discussion for all topics', | |
| privacy: 'public', | |
| allowedUserIds: [], | |
| }, | |
| { | |
| _id: oid('g2b3c4d5e6f7a8b9c0d1e2f3'), | |
| title: 'Technology', | |
| description: 'Tech news, software, and innovation', | |
| privacy: 'public', | |
| allowedUserIds: [], | |
| }, | |
| { | |
| _id: oid('g3c4d5e6f7a8b9c0d1e2f3a4'), | |
| title: 'Philosophy', | |
| description: 'Ideas, ethics, and ways of thinking', | |
| privacy: 'public', | |
| allowedUserIds: [], | |
| }, | |
| { | |
| _id: oid('g4d5e6f7a8b9c0d1e2f3a4b5'), | |
| title: 'Politics & Society', | |
| description: 'Civic discourse and social issues', | |
| privacy: 'public', | |
| allowedUserIds: [], | |
| }, | |
| { | |
| _id: oid('g5e6f7a8b9c0d1e2f3a4b5c6'), | |
| title: 'Science', | |
| description: 'Research, discoveries, and evidence-based discussion', | |
| privacy: 'public', | |
| allowedUserIds: [], | |
| }, | |
| { | |
| _id: oid('g6f7a8b9c0d1e2f3a4b5c6d7'), | |
| _id: oid('a1a2b3c4d5e6f7a8b9c0d1e2'), | |
| title: 'General', | |
| description: 'General discussion for all topics', | |
| privacy: 'public', | |
| allowedUserIds: [], | |
| }, | |
| { | |
| _id: oid('b2b3c4d5e6f7a8b9c0d1e2f3'), | |
| title: 'Technology', | |
| description: 'Tech news, software, and innovation', | |
| privacy: 'public', | |
| allowedUserIds: [], | |
| }, | |
| { | |
| _id: oid('c3c4d5e6f7a8b9c0d1e2f3a4'), | |
| title: 'Philosophy', | |
| description: 'Ideas, ethics, and ways of thinking', | |
| privacy: 'public', | |
| allowedUserIds: [], | |
| }, | |
| { | |
| _id: oid('d4d5e6f7a8b9c0d1e2f3a4b5'), | |
| title: 'Politics & Society', | |
| description: 'Civic discourse and social issues', | |
| privacy: 'public', | |
| allowedUserIds: [], | |
| }, | |
| { | |
| _id: oid('e5e6f7a8b9c0d1e2f3a4b5c6'), | |
| title: 'Science', | |
| description: 'Research, discoveries, and evidence-based discussion', | |
| privacy: 'public', | |
| allowedUserIds: [], | |
| }, | |
| { | |
| _id: oid('f6f7a8b9c0d1e2f3a4b5c6d7'), |
| {/* Title — no label, placeholder only (matches monorepo InputBase) */} | ||
| <Input | ||
| id="title" | ||
| placeholder="Enter Title" | ||
| {...register('title')} | ||
| className={cn('text-lg border-0 shadow-none px-0 focus-visible:ring-0 rounded-none', errors.title && 'border-b border-destructive')} | ||
| /> | ||
| {errors.title && ( | ||
| <p className="text-sm text-destructive mt-1">{errors.title.message}</p> | ||
| )} | ||
|
|
||
| <div className="border-t my-2" /> | ||
|
|
||
| {/* Content — scrollable, no label, placeholder only (matches monorepo) */} | ||
| <div className="flex-1 flex flex-col min-h-0 overflow-auto"> | ||
| <Textarea | ||
| id="text" | ||
| placeholder="Enter your post content (no links allowed)" | ||
| {...register('text')} | ||
| className={cn( |
There was a problem hiding this comment.
The Title and Content fields no longer have associated labels (placeholders only). Placeholders are not a reliable accessible name and disappear on input, which hurts screen reader usability. Add an accessible label (e.g., <Label className="sr-only" htmlFor="title">Title</Label> / similar for text) or aria-label/aria-labelledby on the inputs.
| if (citationUrl && !sanitizedCitationUrl) { | ||
| setError({ message: 'Invalid URL format.' }) | ||
| setShowAlert(true) | ||
| return | ||
| } | ||
|
|
There was a problem hiding this comment.
The if (citationUrl && !sanitizedCitationUrl) guard is effectively redundant because submitPostSchema already rejects invalid citationUrl values via refine, so onSubmit should only run when sanitizeUrl(citationUrl) is non-null. Removing this avoids dead code and keeps validation/error reporting in one place (RHF field error vs. modal alert).
| if (citationUrl && !sanitizedCitationUrl) { | |
| setError({ message: 'Invalid URL format.' }) | |
| setShowAlert(true) | |
| return | |
| } |
| {/* Create Quote Dialog */} | ||
| <Dialog open={submitDialogOpen} onOpenChange={setSubmitDialogOpen}> | ||
| <DialogContent className="max-w-md p-0" showCloseButton={false}> | ||
| <SubmitPost setOpen={setSubmitDialogOpen} /> | ||
| </DialogContent> |
There was a problem hiding this comment.
The new “Create Quote” dialog is missing a DialogTitle/DialogDescription. Without an accessible title, screen readers may not announce the dialog context and Radix will typically warn. Add a DialogTitle (can be sr-only) inside DialogContent (e.g., “Create Quote”).
| {/* Create Quote Dialog */} | ||
| <Dialog open={submitDialogOpen} onOpenChange={setSubmitDialogOpen}> | ||
| <DialogContent className="max-w-md p-0" showCloseButton={false}> | ||
| <SubmitPost setOpen={setSubmitDialogOpen} /> | ||
| </DialogContent> |
There was a problem hiding this comment.
This dialog instance doesn’t include a DialogTitle/DialogDescription. For accessibility (Radix Dialog), add an accessible title (even sr-only) so assistive tech can announce the dialog (e.g., “Create Quote”).
Fix: create post issues, plus navbar bar create post button resolved