fix: dropdown menu not opening on avatar click

React synthetic event stopPropagation doesn't stop native document
listeners (React 17+ attaches to root, document listener is separate).
The document click handler was closing the menu right after avatar
opened it. Now it checks if the click target is inside the dropdown
or on the avatar and skips closing.
This commit is contained in:
lezi-fun committed 2026-08-10 14:38:30 +08:00
1 parent 2a508d1b21
commit c171efc1ec
5 files changed
+38 -9

No files matched your search

+1 -1
View File
@@ -12,7 +12,7 @@ export async function GET(req, { params }) {
if (!UUID_RE.test(params.id)) return invalidId();
try {
const r = await pool.query(
`SELECT p.*, u.username, u.avatar_url
`SELECT p.*, u.username, u.avatar_url, u.signature
FROM posts p
JOIN users u ON p.user_id = u.id
WHERE p.id = $1`,
+1 -1
View File
@@ -10,7 +10,7 @@ export async function PUT(req, { params }) {
}
const body = await req.json();
const { username, bio, role } = body;
const { username, bio, signature, role } = body;
// 改角色:仅管理员
if (role !== undefined) {