Anujcodecraft / Anujcodecraft/notes-online

## 🐞 Bug: "Next" Button Enabled Even When No More Data is Available (Pagination)

Đang mở
#23 5 bình luận 0 reaction 1 người được giao Được giao cho @devi5040 Xem trên GitHub
bug good first issue help wanted NodeJS ReactJs
Ngôn ngữ chính
JavaScript
Star
7
Fork
7
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### 📋 Description

On paginated pages (e.g., **PYQs and Notes**), when the user is **not on the last page by number**, but the **remaining items to show are already fewer than the page size**, the **"Next"** button is still enabled.

- This leads to the next page showing **no content**, creating a poor user experience.

---

### 🔁 Steps to Reproduce

1. Have a dataset with, for example, **11 items**, and pagination limit is **6 per page**.
2. Page 1 shows 6 items.
3. Page 2 shows remaining 5 items.
4. Page 3 should **not exist**, but the **"Next"** button is still enabled.
5. Clicking "Next" shows an empty page.
6. Do check [🌐 Live Demo](https://manitstudyportal.netlify.app/) here for live bug
---

### ❌ Current Behavior

- "Next" button is enabled even when there are no more items to show.
- Clicking it leads to a blank or empty result.

---

### ✅ Expected Behavior

- Backend should return a **flag (e.g., `isLastPage: true`)** when the current set of items is the last.
- Frontend should check this flag and **disable the "Next"** button accordingly.
- Alternatively, the frontend can calculate based on total count and limit, but a backend flag would be cleaner and more reliable.

---

### 💡 Suggested Fix

- **Backend**: Add a field like `isLastPage: true/false` in controller of getting items (notes and pyqs)
- **Frontend**: Disable the "Next" button if `isLastPage === true`

---

### 📂 Affected Areas

- Backend pagination API logic
- Client pagination button state

---

### 🏷️ Labels

`bug` `pagination` `backend` `frontend` `good first issue`

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.