Commit fa8afc8
authored
fix(presentation-editor): arrow key scroll-into-view with unconstrained containers (SD-1950) (#2411)
* fix(presentation-editor): revalidate scroll container after first layout (SD-1950)
Arrow key navigation was not auto-scrolling to keep the cursor visible
when the consumer's container had overflow:auto but no height constraint.
The root cause was in #findScrollableAncestor — at setup time it picks the
first ancestor with overflow-y:auto|scroll, but cannot verify the element
actually constrains content height (content isn't laid out yet). When the
consumer sets overflow:auto without a height constraint, the container
expands to fit all content instead of scrolling, making scrollHeight equal
to clientHeight. This caused three cascading failures:
1. Caret scroll-into-view: getBoundingClientRect() on the ~15000px container
always contained the caret, so the scroll condition never triggered.
2. Virtualization: domPainter received the wrong scroll container, computing
page visibility against the full container instead of the viewport.
3. Scroll offset calculations: all scroll-relative logic used a container
that never actually scrolled.
The fix adds #revalidateScrollContainer(), called once after the first
layout completes. At that point content is laid out and we can check
scrollHeight vs clientHeight. If the detected container isn't actually
scrollable, we walk further up the DOM to find one that is, or fall back
to window — then update the scroll listener and domPainter reference.
* fix(presentation-editor): address scroll container revalidation edge cases
Two fixes based on review feedback:
1. Avoid falsely switching away from properly constrained containers.
A container with height:600px and overflow:auto may not overflow on
first layout if the document is short. The previous check would
switch to window in that case and never retry. Now we also verify
the container grew beyond the viewport before switching — a clear
signal its height is unconstrained.
2. Clear domPainter scroll container when falling back to window.
When revalidation resolves to window, the domPainter was keeping
the stale HTMLElement reference from #ensurePainter. Now we pass
null, which makes the domPainter use viewport-based calculations.1 parent d23c515 commit fa8afc8
1 file changed
Lines changed: 56 additions & 0 deletions
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
| 319 | + | |
319 | 320 | | |
320 | 321 | | |
321 | 322 | | |
| |||
3098 | 3099 | | |
3099 | 3100 | | |
3100 | 3101 | | |
| 3102 | + | |
| 3103 | + | |
| 3104 | + | |
| 3105 | + | |
| 3106 | + | |
| 3107 | + | |
| 3108 | + | |
| 3109 | + | |
| 3110 | + | |
| 3111 | + | |
| 3112 | + | |
| 3113 | + | |
| 3114 | + | |
| 3115 | + | |
| 3116 | + | |
| 3117 | + | |
| 3118 | + | |
| 3119 | + | |
| 3120 | + | |
| 3121 | + | |
| 3122 | + | |
| 3123 | + | |
| 3124 | + | |
| 3125 | + | |
| 3126 | + | |
| 3127 | + | |
| 3128 | + | |
| 3129 | + | |
| 3130 | + | |
| 3131 | + | |
| 3132 | + | |
| 3133 | + | |
| 3134 | + | |
| 3135 | + | |
| 3136 | + | |
| 3137 | + | |
| 3138 | + | |
| 3139 | + | |
| 3140 | + | |
| 3141 | + | |
| 3142 | + | |
| 3143 | + | |
| 3144 | + | |
| 3145 | + | |
| 3146 | + | |
| 3147 | + | |
| 3148 | + | |
| 3149 | + | |
| 3150 | + | |
| 3151 | + | |
| 3152 | + | |
| 3153 | + | |
| 3154 | + | |
| 3155 | + | |
3101 | 3156 | | |
3102 | 3157 | | |
3103 | 3158 | | |
| |||
3862 | 3917 | | |
3863 | 3918 | | |
3864 | 3919 | | |
| 3920 | + | |
3865 | 3921 | | |
3866 | 3922 | | |
3867 | 3923 | | |
| |||
0 commit comments