Commit ca65338
authored
fix(core): scroll-spy race conditions on rapid/smooth scroll (#2968)
* fix(core): scroll-spy race conditions on rapid/smooth scroll navigation
Fixes three bugs in ScrollSpyController:
1. Rapid clicks: setActive() now cancels previous force state via
AbortController before establishing new force, preventing stale
listeners from releasing force prematurely.
2. Force release timing: replaced await-first-intersection approach with
scrollend event listener (+ 3s safety timeout). The old approach
released force when any IO fired during smooth scroll, causing
intermediate sections to steal the active state.
3. Non-contiguous sections: passedLinks are now sorted by DOM order
instead of relying on Set insertion order, which was unreliable
when sections had untracked content between them.
Also fixes a safeguard bug where the #nextIntersection timeout set
`#intersected = false` (should be `true`), which could cause an infinite
rAF loop, and fixes the boundary comparison to use rootBounds.top
instead of intersectionRect.top so elements exactly at the viewport
top are correctly considered "passed".
Closes #2911
Closes #2920
Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
* docs: add changeset
Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(core): clear #nextIntersection safeguard timeout on exit
Prevents a stale 3s timeout from prematurely resolving a subsequent
#nextIntersection() call.
Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 8b88e14 commit ca65338
3 files changed
Lines changed: 401 additions & 9 deletions
File tree
- .changeset
- core/pfe-core
- controllers
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
66 | 72 | | |
67 | 73 | | |
68 | 74 | | |
| |||
144 | 150 | | |
145 | 151 | | |
146 | 152 | | |
| 153 | + | |
147 | 154 | | |
148 | 155 | | |
149 | 156 | | |
150 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
151 | 170 | | |
152 | 171 | | |
153 | 172 | | |
| |||
193 | 212 | | |
194 | 213 | | |
195 | 214 | | |
196 | | - | |
197 | | - | |
| 215 | + | |
| 216 | + | |
198 | 217 | | |
199 | 218 | | |
200 | 219 | | |
| 220 | + | |
201 | 221 | | |
202 | 222 | | |
203 | 223 | | |
204 | 224 | | |
205 | | - | |
| 225 | + | |
| 226 | + | |
206 | 227 | | |
207 | 228 | | |
208 | 229 | | |
209 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
210 | 235 | | |
211 | 236 | | |
212 | | - | |
213 | | - | |
214 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
215 | 243 | | |
216 | 244 | | |
217 | 245 | | |
| |||
242 | 270 | | |
243 | 271 | | |
244 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
245 | 277 | | |
246 | 278 | | |
| 279 | + | |
247 | 280 | | |
248 | 281 | | |
249 | 282 | | |
250 | 283 | | |
251 | 284 | | |
252 | 285 | | |
253 | 286 | | |
254 | | - | |
255 | | - | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
256 | 294 | | |
257 | 295 | | |
0 commit comments