Skip to content

Added dialog feature to posts#79

Open
wasaniUB wants to merge 5 commits intostagingfrom
wasani/posts-dialog-change
Open

Added dialog feature to posts#79
wasaniUB wants to merge 5 commits intostagingfrom
wasani/posts-dialog-change

Conversation

@wasaniUB
Copy link
Collaborator

@wasaniUB wasaniUB commented Feb 8, 2026

Added a feature where posts were clickable and would show more information when clicked. For the earlier pull request, I accidentally had the base branch as main and not staging.

@wasaniUB wasaniUB requested a review from AlexDev404 February 8, 2026 02:45
@AlexDev404
Copy link
Member

Added a feature where posts were clickable and would show more information when clicked. For the earlier pull request, I accidentally had the base branch as main and not staging.

Okay, for sure. Reviewing now. Will update you shortly.

@AlexDev404 AlexDev404 requested a review from Copilot February 8, 2026 06:31
Copy link
Contributor

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

Adds a post-details dialog so users can click a post card to view more information inline.

Changes:

  • Add clickable post cards that open a details dialog in the public posts page
  • Introduce dialog state management (selectedPost/showDialog) and close handling
  • Add dialog UI import in the dashboard posts page (plus whitespace-only changes)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
src/routes/dashboard/posts/+page.svelte Adds Dialog import (and whitespace) in preparation for a dialog feature
src/routes/(app)/posts/+page.svelte Makes posts clickable and displays post details in a modal dialog

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +56 to +59
<Card.Root
class="p-6 transition-transform hover:scale-105 cursor-pointer"
onclick={() => openPost(post)}
>
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

A clickable card needs keyboard accessibility. Consider using a semantic interactive element (e.g., a or ) or add appropriate attributes/handlers (role="button", tabindex="0", and key handling for Enter/Space) so keyboard and assistive technology users can open the post dialog.

Copilot uses AI. Check for mistakes.
Comment on lines +90 to +92
{#if selectedPost}
<Dialog.Root open={showDialog} onOpenChange={closePost}>
<Dialog.Content class="max-w-2xl">
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

The open-change handler unconditionally calls closePost(). If the Dialog component invokes onOpenChange with the next open state (common pattern), this will also run when opening and immediately close the dialog. Update the handler to accept the next state and only clear selectedPost when the dialog is closing (or use the library’s recommended bind pattern, e.g., bind:open, and react to open=false).

Copilot uses AI. Check for mistakes.
Comment on lines +106 to +113
<div class="mt-6 flex justify-end">
<button
class="px-4 py-2 rounded bg-primary text-background"
onclick={closePost}
>
Close
</button>
</div>
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

Prefer using the dialog library’s close primitive (e.g., Dialog.Close / CloseButton / asChild pattern, depending on your dialog wrapper) instead of a custom close handler. This typically ensures consistent behavior (focus restoration, correct event wiring) and reduces the risk of state drift between showDialog and the dialog’s internal state.

Copilot uses AI. Check for mistakes.
AlexDev404 and others added 2 commits February 9, 2026 20:33
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Member

@AlexDev404 AlexDev404 left a comment

Choose a reason for hiding this comment

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

Image

Nothing seems to show up.

Comment on lines +11 to +12

let selectedPost: any = null;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let selectedPost: any = null;
let selectedPost: any = $state(null);

Copy link
Member

Choose a reason for hiding this comment

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

@wasaniUB Since this is reactive, you need to use $state()

const { posts } = data;

let selectedPost: any = null;
let showDialog = false;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let showDialog = false;
let showDialog = $state(false);

Always use $state() for elements that you want to update dynamically later on

let selectedPost: any = null;
let showDialog = false;

function openPost(post: any) {
Copy link
Member

Choose a reason for hiding this comment

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

@wasaniUB You need to have a type for post. Do not use "any". Consider making an interface

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.

3 participants