Skip to content

fix: post deletion permissions, modal focus ring, and dropdown hover#3

Merged
canghai118 merged 3 commits into
linkcraftstudio:mainfrom
canghai118:main
May 25, 2026
Merged

fix: post deletion permissions, modal focus ring, and dropdown hover#3
canghai118 merged 3 commits into
linkcraftstudio:mainfrom
canghai118:main

Conversation

@canghai118
Copy link
Copy Markdown
Contributor

Summary

Three focused bug fixes:

  • fix(post): restrict post deletion to moderatorsDELETE /api/admin/posts/[id] and usePermission now gate post deletion behind moderator role instead of allowing broader access.
  • fix(post): suppress initial focus ring in PostDetailModal — the modal no longer shows a stray focus ring on open.
  • fix(ui): unify Delete dropdown hover style with EditCommentItem and PostDetail Delete actions now use the same hover styling as Edit for visual consistency.

Changes

File
server/api/admin/posts/[id].delete.ts moderator-only deletion
app/composables/usePermission.ts permission gate
app/components/post/PostDetailModal.vue suppress initial focus ring
app/components/comment/CommentItem.vue unify Delete hover
app/components/post/PostDetail.vue unify Delete hover

Test plan

  • Non-moderator cannot delete posts (UI hidden + API returns 403)
  • Opening a post modal shows no stray focus ring
  • Delete dropdown hover matches Edit

Prevent Radix Dialog auto-focus so opening via a non-focusable trigger
(e.g. an <article> card) doesn't paint a focus-visible ring on the first
tabbable element.
Remove the author self-delete bypass in the admin delete handler so the
endpoint matches the rest of /api/admin/posts/* (moderator-only). Authors
keep their edit path via PATCH /api/posts/:id; deletion is a community-
level action because shipped posts carry others' upvotes, comments, and
status changes.

Split canDelete in usePermission by resource type — posts moderator-only,
comments still author-or-moderator (conversational).
Custom --accent is salmon, so focus:bg-accent + focus:text-destructive
produced red-on-orange. Drop focus:text-destructive and let the default
focus:text-accent-foreground (white) take over on hover.
@canghai118 canghai118 merged commit 9d08311 into linkcraftstudio:main May 25, 2026
2 checks passed
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.

1 participant