Commit 84af4c0
authored
fix(virtualization): correct scroll mapping and viewport sizing at non-100% zoom (#2171)
* fix(virtualization): correct scroll mapping and viewport sizing at non-100% zoom
Fix blank pages and excess scroll space when zoomed out in long documents.
Three interrelated bugs caused the virtualization system to break at
zoom != 100%:
1. updateVirtualWindow() used getBoundingClientRect().top (screen-space,
affected by CSS transform: scale) but compared against virtualOffsets
(layout-space, unscaled). Divide by zoom factor to fix.
2. PresentationEditor used 24px page gap for viewport height calculation
while DomPainter virtualization defaulted to 72px. Normalize the
virtualization gap to match the effective page gap.
3. CSS transform: scale() does not change layout box dimensions. At
zoom < 1, painterHost's unscaled CSS box overflowed viewportHost,
inflating the scroll range. Use explicit height + overflow: hidden
on viewportHost to clip the CSS box.
* fix(zoom): ensure zoom controls work on blank documents
Blank documents created by the store lacked an `id`, causing the
PresentationEditor instance to not register in the static `#instances`
map. When `setGlobalZoom()` iterated the map it found nothing, so
zoom CSS transforms were never applied.
Two fixes:
- Add `id: uuidv4()` to the blank document config in superdoc-store
- Always register PresentationEditor instances with a fallback key
when `documentId` is not provided, ensuring `setGlobalZoom` works
regardless of document configuration
* fix(virtualization): address PR review — registryKey, overflow clipping, zoom test
- Replace options.documentId mutation with #registryKey private field
- Replace overflow:hidden with negative margin-bottom on painterHost
to avoid clipping collaboration cursor labels
- Add zoom × virtualization interaction test for non-scrollable container
* test(virtualization): tighten zoom assertions and add behavior test
Tighten the zoom × virtualization unit test to assert exact page indices
[7, 8, 9] instead of loose range checks that pass on buggy behavior.
Add a Playwright behavior test that generates a long document, sets 75%
zoom, scrolls to mid-document, and verifies content is visible (not
blank). This guards against regressions when virtualization or zoom code
changes.1 parent c7efa85 commit 84af4c0
5 files changed
Lines changed: 221 additions & 14 deletions
File tree
- packages
- layout-engine/painters/dom/src
- super-editor/src/core/presentation-editor
- tests/behavior/tests/virtualization
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
125 | 126 | | |
126 | 127 | | |
127 | 128 | | |
| |||
167 | 168 | | |
168 | 169 | | |
169 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
170 | 175 | | |
171 | 176 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1026 | 1026 | | |
1027 | 1027 | | |
1028 | 1028 | | |
| 1029 | + | |
| 1030 | + | |
1029 | 1031 | | |
1030 | 1032 | | |
1031 | 1033 | | |
| |||
1083 | 1085 | | |
1084 | 1086 | | |
1085 | 1087 | | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
1086 | 1108 | | |
1087 | 1109 | | |
1088 | 1110 | | |
| |||
1612 | 1634 | | |
1613 | 1635 | | |
1614 | 1636 | | |
1615 | | - | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
1616 | 1641 | | |
| 1642 | + | |
1617 | 1643 | | |
1618 | 1644 | | |
1619 | 1645 | | |
1620 | 1646 | | |
1621 | 1647 | | |
1622 | 1648 | | |
1623 | | - | |
1624 | | - | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
1625 | 1652 | | |
1626 | 1653 | | |
1627 | 1654 | | |
| |||
Lines changed: 51 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
369 | 369 | | |
370 | 370 | | |
371 | 371 | | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
372 | 423 | | |
373 | 424 | | |
374 | 425 | | |
| |||
Lines changed: 47 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| 266 | + | |
| 267 | + | |
266 | 268 | | |
267 | 269 | | |
268 | 270 | | |
| |||
612 | 614 | | |
613 | 615 | | |
614 | 616 | | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
619 | 622 | | |
620 | 623 | | |
621 | 624 | | |
| |||
2313 | 2316 | | |
2314 | 2317 | | |
2315 | 2318 | | |
| 2319 | + | |
| 2320 | + | |
2316 | 2321 | | |
2317 | 2322 | | |
2318 | 2323 | | |
| |||
2398 | 2403 | | |
2399 | 2404 | | |
2400 | 2405 | | |
2401 | | - | |
2402 | | - | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
2403 | 2409 | | |
2404 | 2410 | | |
2405 | 2411 | | |
| |||
3551 | 3557 | | |
3552 | 3558 | | |
3553 | 3559 | | |
| 3560 | + | |
| 3561 | + | |
| 3562 | + | |
| 3563 | + | |
| 3564 | + | |
| 3565 | + | |
| 3566 | + | |
| 3567 | + | |
3554 | 3568 | | |
3555 | 3569 | | |
3556 | 3570 | | |
3557 | 3571 | | |
3558 | | - | |
| 3572 | + | |
3559 | 3573 | | |
3560 | 3574 | | |
3561 | 3575 | | |
3562 | 3576 | | |
3563 | | - | |
| 3577 | + | |
3564 | 3578 | | |
| 3579 | + | |
| 3580 | + | |
| 3581 | + | |
| 3582 | + | |
| 3583 | + | |
3565 | 3584 | | |
3566 | 3585 | | |
3567 | 3586 | | |
| |||
5037 | 5056 | | |
5038 | 5057 | | |
5039 | 5058 | | |
| 5059 | + | |
| 5060 | + | |
5040 | 5061 | | |
5041 | 5062 | | |
5042 | 5063 | | |
5043 | 5064 | | |
| 5065 | + | |
| 5066 | + | |
| 5067 | + | |
| 5068 | + | |
5044 | 5069 | | |
5045 | 5070 | | |
5046 | 5071 | | |
| |||
5059 | 5084 | | |
5060 | 5085 | | |
5061 | 5086 | | |
| 5087 | + | |
| 5088 | + | |
| 5089 | + | |
| 5090 | + | |
| 5091 | + | |
| 5092 | + | |
5062 | 5093 | | |
5063 | 5094 | | |
5064 | 5095 | | |
5065 | | - | |
5066 | 5096 | | |
5067 | 5097 | | |
5068 | 5098 | | |
| 5099 | + | |
| 5100 | + | |
5069 | 5101 | | |
5070 | 5102 | | |
5071 | | - | |
5072 | | - | |
| 5103 | + | |
| 5104 | + | |
| 5105 | + | |
| 5106 | + | |
| 5107 | + | |
5073 | 5108 | | |
5074 | 5109 | | |
| 5110 | + | |
5075 | 5111 | | |
5076 | 5112 | | |
5077 | 5113 | | |
| |||
Lines changed: 88 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
0 commit comments