Skip to content

Fix/post quote#329

Merged
motirebuma merged 2 commits intomainfrom
fix/post-quote
Apr 19, 2026
Merged

Fix/post quote#329
motirebuma merged 2 commits intomainfrom
fix/post-quote

Conversation

@motirebuma
Copy link
Copy Markdown
Collaborator

Fix: create post issues, plus navbar bar create post button resolved

Copilot AI review requested due to automatic review settings April 19, 2026 12:47
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
quotevote Ready Ready Preview, Comment Apr 19, 2026 0:47am

@motirebuma motirebuma merged commit de8eed6 into main Apr 19, 2026
6 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_GROUPS and switched SubmitPost to use mock groups instead of querying groups from the API.
  • Refactored SubmitPostForm layout (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.

Comment on lines 3 to 23
@@ -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 }}
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +222 to +229
{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>
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 367 to 371
{/* 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>
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 339 to 342
<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>
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +15 to +50
_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'),
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
_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'),

Copilot uses AI. Check for mistakes.
Comment on lines +197 to +216
{/* 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(
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +74 to +79
if (citationUrl && !sanitizedCitationUrl) {
setError({ message: 'Invalid URL format.' })
setShowAlert(true)
return
}

Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
if (citationUrl && !sanitizedCitationUrl) {
setError({ message: 'Invalid URL format.' })
setShowAlert(true)
return
}

Copilot uses AI. Check for mistakes.
Comment on lines +504 to +508
{/* Create Quote Dialog */}
<Dialog open={submitDialogOpen} onOpenChange={setSubmitDialogOpen}>
<DialogContent className="max-w-md p-0" showCloseButton={false}>
<SubmitPost setOpen={setSubmitDialogOpen} />
</DialogContent>
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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”).

Copilot uses AI. Check for mistakes.
Comment on lines +466 to +470
{/* Create Quote Dialog */}
<Dialog open={submitDialogOpen} onOpenChange={setSubmitDialogOpen}>
<DialogContent className="max-w-md p-0" showCloseButton={false}>
<SubmitPost setOpen={setSubmitDialogOpen} />
</DialogContent>
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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”).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants