From 2dac79e5f55b0d1fcb46991cabcfd9939b726036 Mon Sep 17 00:00:00 2001 From: ngthanhvu Date: Mon, 10 Aug 2026 00:22:54 -0400 Subject: [PATCH] feat(admin): smart dropdown positioning, filter & pagination fixes - Add getDropdownPosition() to handle table dropdown placement dynamically - Remove overflow-hidden on admin-card so dropdowns aren't clipped - Fix totalPages calculation using total/limit instead of missing API field - Add role/status filters + full pagination to member page - Create .agents/admin-ui-pitfalls.md for future reference --- .agents/admin-ui-pitfalls.md | 135 +++++++++++++++++++++++++++++++++ app/pages/admin/phim/index.vue | 24 ++++-- app/pages/admin/thanh-vien.vue | 66 +++++++++++----- 3 files changed, 199 insertions(+), 26 deletions(-) create mode 100644 .agents/admin-ui-pitfalls.md diff --git a/.agents/admin-ui-pitfalls.md b/.agents/admin-ui-pitfalls.md new file mode 100644 index 0000000..35961c4 --- /dev/null +++ b/.agents/admin-ui-pitfalls.md @@ -0,0 +1,135 @@ +# Admin Panel UI Pitfalls & Patterns + +## 1. Dropdowns Inside Tables — Always Use Smart Positioning + +**❌ Đừng bao giờ viết cứng** `top-full mt-1` hoặc `bottom-full mb-1` cho dropdown trong table: + +```vue + +
+ + +
+``` + +**✅ Đúng — dùng computed position dựa trên index:** + +```ts +// Helper để dropdown luôn hiển thị bên trong vùng nhìn thấy +function getDropdownPosition(index: number) { + const total = items.value?.length || 0 + // Chỉ mở lên trên khi còn ít nhất 2 hàng phía dưới + if (total <= 2 || index < total - 2) { + return 'top-full mt-1' + } + return 'bottom-full mb-1' +} +``` + +```vue + +``` + +### Rule Checklist: +- [ ] Mỗi cell có dropdown cần `relative` wrapper +- [ ] Hàm `getDropdownPosition` nhận index từ `items.indexOf(item)` +- [ ] Dùng dynamic class binding, KHÔNG hardcode vị trí +- [ ] Kiểm tra khi item nằm ở hàng cuối cùng của bảng + +--- + +## 2. Table Clipping — Remove `overflow-hidden` on Card Wrappers + +Khi table có dropdown/menu, `.admin-card overflow-hidden` sẽ cắt mất dropdown khi nó mở ra ngoài vùng chứa. + +**✅ Luôn bỏ `overflow-hidden` hoặc override bằng `overflow-visible!`:** + +```vue + +
+``` + +> **Lưu ý Tailwind v4 syntax**: dùng `overflow-visible!` chứ KHÔNG phải `!overflow-visible`. Linter sẽ báo lỗi nếu viết sai. + +--- + +## 3. Admin Light Mode — Hardcoded Colors Need Override + +Các component admin dùng hardcode màu dark mode (`bg-[#131418]`, `text-white`, `border-white/6`) không tự động chuyển khi xem trong light mode. Cần xử lý theo thứ tự ưu tiên: + +### Thứ tự xử lý đúng: + +1. **Preference 1**: Đổi trực tiếp template sang light-mode colors (`bg-white`, `border-slate-200`, `text-slate-900`) +2. **Preference 2**: Thêm rule CSS vào `.agents/admin-light-palette.md` nếu nhiều nơi share style +3. **Last resort**: Dùng CSS selector override trong layout `