Commit da554f4
delegate scroll-to-selected to reka's highlightSelected
The manual scroll math in scrollToSelectedOption was redundant and
slightly wrong: Reka's highlightSelected() already triggers
virtualFocusHook, which calls virtualizer.scrollToIndex(index) on the
underlying TanStack virtualizer. The manual block was running on top of
that, second-guessing it with a hardcoded estimatedItemHeight of 40px.
That estimate matched the virtualizer's :estimate-size, but real items
vary by size variant (xs items render closer to ~28px, xl closer to
~48px) and by custom slot content, so the "centered" position drifted
off-center. Worse, it raced Reka's own scroll on the next frame, so the
final scrollTop depended on which rAF resolved last.
Dropping the manual math means the selected option lands wherever Reka
puts it (align: 'start' by default), which is the standard dropdown
behavior and works correctly across all sizes and slot content.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 9ccf738 commit da554f4
1 file changed
Lines changed: 2 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
336 | | - | |
| 336 | + | |
337 | 337 | | |
338 | 338 | | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
| 339 | + | |
355 | 340 | | |
356 | 341 | | |
357 | 342 | | |
| |||
0 commit comments