[PR #7083] feat(clients): fit the table to the viewport so toolbar and scrollbar stay visible #6637

Open
opened 2026-11-07 14:34:19 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/7083
Author: @Mo7amadd
Created: 11/5/2026
Status: 🔄 Open

Base: main ← Head: feat/clients-fit-table-height


📝 Commits (1)

  • f6e42ac feat(clients): fit the table to the viewport so toolbar and scrollbar stay visible

📊 Changes

2 files changed (+68 additions, -22 deletions)

View changed files

📝 frontend/src/pages/clients/ClientsPage.tsx (+28 -22)
➕ frontend/src/pages/clients/useFitTableBodyHeight.ts (+40 -0)

📄 Description

Summary

On desktop, the Clients table body now gets a height that fits the viewport (scroll.y), so the rows scroll inside the table while the toolbar, the column headers, the horizontal scrollbar and the pagination stay on screen.

Why

With 100 or 200 rows per page, the search/filter bar scrolls away immediately, and the horizontal scrollbar sits at the very bottom of the page. On a laptop you scroll to the end of the list just to move the table sideways, then back up to find the row again.

What changed

  • useFitTableBodyHeight.ts: measures where the table body starts and how much sits below the table inside its card (pagination, padding) and the page's bottom padding, and returns viewport − those, with a 240px floor. It re-measures on window resize and, via a ResizeObserver on every card in the content area, whenever something above the table changes size (filter chips, the selection bar). The hook takes the element from a ref callback, so it needs no effect of its own to wait for the DOM.
  • ClientsPage.tsx: the desktop <Table> is wrapped in a div that provides that element, and scroll gets y: fitBodyHeight. antd then fixes the header and puts the scroller on the body, which is its standard layout for a bounded-height table.

Type of change

  • New feature

Areas affected

  • Frontend (UI / panel pages)

How was this tested?

  • npm run typecheck, npm run lint, npm run format:check, npm run build and npm run build-storybook pass; the existing unit and component suites pass.
  • No automated test: this is pure layout measurement, which jsdom cannot reach. The manual check that demonstrates it, in npm run dev with a mocked API (120 clients): at 1280×650, 1366×768, 1440×820 and 1920×900, with 25 and 200 rows per page, the card's bottom edge stays 16px above the viewport bottom and document.scrollingElement.scrollHeight === innerHeight (no page scrollbar); resizing the window, adding and removing filter chips, and switching to and from the mobile breakpoint all re-fit the table.

Screenshots / recordings

fit-1366x700

Breaking changes

None functionally. Visually, rows now scroll inside the table on desktop instead of with the page.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable). (Layout only; see above.)
  • go build ./... and the test suite pass locally. (Frontend-only change; no Go code touched, so the Go suite was not run.)
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/7083 **Author:** [@Mo7amadd](https://github.com/Mo7amadd) **Created:** 11/5/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/clients-fit-table-height` --- ### 📝 Commits (1) - [`f6e42ac`](https://github.com/MHSanaei/3x-ui/commit/f6e42ac92d9032cc234ec3c449db7294a24ff43d) feat(clients): fit the table to the viewport so toolbar and scrollbar stay visible ### 📊 Changes **2 files changed** (+68 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/pages/clients/ClientsPage.tsx` (+28 -22) ➕ `frontend/src/pages/clients/useFitTableBodyHeight.ts` (+40 -0) </details> ### 📄 Description ## Summary On desktop, the Clients table body now gets a height that fits the viewport (`scroll.y`), so the rows scroll inside the table while the toolbar, the column headers, the horizontal scrollbar and the pagination stay on screen. ## Why With 100 or 200 rows per page, the search/filter bar scrolls away immediately, and the horizontal scrollbar sits at the very bottom of the page. On a laptop you scroll to the end of the list just to move the table sideways, then back up to find the row again. ## What changed - `useFitTableBodyHeight.ts`: measures where the table body starts and how much sits below the table inside its card (pagination, padding) and the page's bottom padding, and returns `viewport − those`, with a 240px floor. It re-measures on window resize and, via a `ResizeObserver` on every card in the content area, whenever something above the table changes size (filter chips, the selection bar). The hook takes the element from a `ref` callback, so it needs no effect of its own to wait for the DOM. - `ClientsPage.tsx`: the desktop `<Table>` is wrapped in a `div` that provides that element, and `scroll` gets `y: fitBodyHeight`. antd then fixes the header and puts the scroller on the body, which is its standard layout for a bounded-height table. ## Type of change - [x] New feature ## Areas affected - [x] Frontend (UI / panel pages) ## How was this tested? - `npm run typecheck`, `npm run lint`, `npm run format:check`, `npm run build` and `npm run build-storybook` pass; the existing unit and component suites pass. - No automated test: this is pure layout measurement, which jsdom cannot reach. The manual check that demonstrates it, in `npm run dev` with a mocked API (120 clients): at 1280×650, 1366×768, 1440×820 and 1920×900, with 25 and 200 rows per page, the card's bottom edge stays 16px above the viewport bottom and `document.scrollingElement.scrollHeight === innerHeight` (no page scrollbar); resizing the window, adding and removing filter chips, and switching to and from the mobile breakpoint all re-fit the table. ## Screenshots / recordings <img width="1291" height="700" alt="fit-1366x700" src="https://github.com/user-attachments/assets/ecc6ba2d-70c4-42ac-875f-68a5b91db6a9" /> ## Breaking changes None functionally. Visually, rows now scroll inside the table on desktop instead of with the page. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [ ] I added or updated tests for the new behavior (when applicable). *(Layout only; see above.)* - [ ] `go build ./...` and the test suite pass locally. *(Frontend-only change; no Go code touched, so the Go suite was not run.)* - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6637
No description provided.