AlistGo / AlistGo/alist-web

User role select only allows single role despite multi-select UI

Đang mở
#312 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
479
Fork
703
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### Describe the bug
The role selector in the Edit/Add User page (`src/pages/manage/users/AddOrEdit.tsx`) renders a multi-select UI (tags with close buttons, checkbox indicators per option), but the underlying `onClick` handler for each `SelectOption` always replaces the entire `role` array with only the clicked role, instead of appending to it.

### Where
`src/pages/manage/users/AddOrEdit.tsx`, inside the role `Select` component:

```tsx
{
// 单选逻辑:如果已选中则移除,否则替换为当前选择
const newRoles = user.role.includes(role.id)
? user.role.filter((id) => id !== role.id)
: [role.id] // 只保留当前选择的角色
setUser("role", newRoles)
}}
>
```

The comment explicitly says "single-select logic" — this appears to be leftover single-select behavior that was never updated when the backend added multi-role support (PR #9215 in AlistGo/alist).

### Expected behavior
Clicking an unselected role should add it to the existing `user.role` array (multi-select), matching the UI (tags, close buttons) that's already built for it:

```tsx
onClick={() => {
const newRoles = user.role.includes(role.id)
? user.role.filter((id) => id !== role.id)
: [...user.role, role.id]
setUser("role", newRoles)
}}
```

### Steps to reproduce
1. Go to admin panel → Users → Edit an existing user
2. Click on Role field, select Role A
3. Click Role B — Role A is silently removed and only Role B remains selected

### Environment
- Alist backend version: v3.64.0
- Backend confirmed to support multi-role per user (see alist-org/alist PR #9215)
- Bug is frontend-only (alist-web)

Happy to submit a PR with the fix above if maintainers confirm this is the intended multi-select behavior.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.