Commit 529dbaf
committed
fix: sync table header scroll with body on horizontal scroll
Closes #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.1 parent 399602a commit 529dbaf
1 file changed
Lines changed: 30 additions & 0 deletions
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
449 | 479 | | |
450 | 480 | | |
451 | 481 | | |
| |||
0 commit comments