[fix] Table header stays aligned during horizontal scroll in InfiniteVirtualTable#4697
Conversation
Closes Agenta-AI#4633 AntD's virtual Table (rc-table with virtual prop) syncs the header's horizontal scroll position with the body internally. However, the sync can drift after: - column visibility changes (columns added/removed) - resizable-column width updates that change scroll.x - other re-renders that reset the header's scrollLeft When drift occurs, the header columns appear misaligned with the body columns whenever the user scrolls horizontally. Fix: add a passive 'scroll' listener on .ant-table-body in InfiniteVirtualTableInner that writes body.scrollLeft → header.scrollLeft on every scroll tick. The effect re-attaches whenever finalColumns or scrollConfig.x changes (the conditions under which drift can occur). In the normal (no-drift) path AntD has already run its own sync handler, so setting the same value is a no-op. When drift has occurred, this listener corrects it on the very next scroll event without any visible glitch.
|
@NamHT4Devlop is attempting to deploy a commit to the agenta projects Team on Vercel. A member of the Team first needs to authorize it. |
|
✅ Thanks @NamHT4Devlop! This PR now meets the contribution requirements and has been reopened. A maintainer will review it soon. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Disabled knowledge base sources:
📝 WalkthroughSummary by CodeRabbit
WalkthroughA ChangesHeader Horizontal Scroll Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Possibly related PRs
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Thanks @NamHT4Devlop for the PR
The demo link links to a 404 can you please update it
|
Hi @mmabrouk, thanks for the feedback! I've updated the demo image — the broken link has been replaced with a working before/after screenshot showing the misaligned vs. aligned header. The CLA has also been signed. Please let me know if anything else needs to be addressed! |
Third main integration on this branch (80 commits, incl. release/v0.103.5, OSS invite hardening, single-project batch fetchers, cascade evaluator selector, table header-scroll-sync). Conflicts resolved, porting main's landed fixes onto the relocated package files (main still edits the OLD oss eval paths this branch moved): - Playground/PlaygroundHeader: kept our re-point to openWorkflowRevisionDrawerAtom (the evaluatorDrawerStore compat bridge was deleted in WP-4 residue B; 3 consumers call the underlying playground-ui atom directly). Took main's isolated-playground evaluator-create feature (currentAppSelection, handleCreatedEvaluator) and threaded its new params (isolatedPlayground/initialAppSelection/postCreateNavigation/onWorkflowCreated) through context: "evaluator-create" instead of the bridge's mode: "create". - agenta-ui InfiniteVirtualTableInner: ported main's .ant-table-header / .ant-table-body scroll-sync useEffect (#4697) into the relocated package copy; removed the leftover deleted oss original. - state/evaluator/evaluatorDrawerStore: accepted our deletion. main's added drawer params already merged into the underlying @agenta/playground-ui workflow-revision-drawer store, so no porting needed. Auto-merged eval package files verified to carry main's changes: - evaluations-ui RunDetails/Page: "SDK Evals" / kind:"custom" typeMap entry (no regression against the Q6 PreviewEvaluationType narrowing). - entities evaluationRun molecule: single-project runBatchFetcher rewrite. - annotation-ui CreateQueueDrawer: multi-select evaluator picker props. Gates: package tsc 0 errors (entities/evaluations/evaluations-ui/annotation/ annotation-ui/ui/playground-ui); lint 0; tests evaluations 133, entities 669, annotation 90. OSS tsc 355 (≤ pre-merge baseline ~363), no new signatures from touched files.
Summary
Fix table header columns becoming misaligned after horizontal scrolling in
InfiniteVirtualTable.Root cause: AntD's virtual table renders
.ant-table-header(overflow: hidden) and.ant-table-body(overflow: auto) as separate DOM elements and syncs their scroll positions internally. However, after column visibility changes orscroll.xupdates trigger a re-render, AntD's internal sync handler is re-registered and may not fire before the next scroll event, causing the header to drift relative to the body.Fix: Add a passive
scrolllistener on.ant-table-bodyinsideInfiniteVirtualTableInnerthat directly writesbody.scrollLeft → header.scrollLefton every scroll tick. The effect re-attaches wheneverfinalColumnsorscrollConfig.xchange — exactly the conditions that cause drift — and runssync()once on mount to correct any drift that happened during the triggering re-render.Testing
Verified locally
Added or updated tests
N/A — this is a DOM-sync side-effect that requires a rendered browser environment to test meaningfully. Manual verification covers the affected scenarios.
QA follow-up
Demo
Before: After scrolling right and then toggling a column, the header row drifts and no longer aligns with the body columns.
After: Header stays perfectly aligned with body columns at all times, including after column visibility or width changes.
Checklist
Closes #4633