-
-
Notifications
You must be signed in to change notification settings - Fork 157
fix(Select): prevent interrupting scroll when virtual select items are added #1830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(Select): prevent interrupting scroll when virtual select items are added #1830
Conversation
…odes, passes through initial flag
🦋 Changeset detectedLatest commit: 5464919 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
On second thought - maybe just a flag to disable the |
I think we should be able to handle this with a simpler solution - The issue really boils down to better support for items added after the content is opened. Right now we basically register the items wehn they mount and call Though it is strange that it is still running the scroll because we have a conditional to return early if a highlighted node already exists. Will look into this, thanks for kicking it off! |
Here's the repro in Stackblitz: https://stackblitz.com/edit/bits-ui-1830-repro The bug looks a little different here - I can scroll two items at a time if I just scroll one notch on my mouse, and if I scroll 2 or 3 notches I actually get set backwards when In this video I am only ever scrolling downwards chrome_D57jxKAgdb.mp4Thanks for looking into this! Let me know if I can help out further! |
Is it because with |
Just realized that preview now doesn't continuously scroll when hovering the scroll down button 🤦♂️ |
Alright we'll go with this solution as I know virtualization is important and this is definitely something we want to support, thanks for taking the time to dig into this and coming up with a solution! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
I came across this bug while trying to implement virtualization with the
shadcn-svelte
Select
component.The flow looks like this:
setInitialHighlightedNode
is called which then highlights and scrolls to the first candidate (non-disabled) Item.My fix highlights and scrolls to the first candidate Item that is within the viewport. This way, we aren't snapping back to an item that has already been scrolled past.
The only part I'm unsure about is the way I got access to the
viewportNode
in theSelectBaseRootState
class:bits-ui/packages/bits-ui/src/lib/bits/select/select.svelte.ts
Line 1260 in b71a01b
Reproduction code (uses
virtua
for virtualization)Before fix:
firefox_Ib3Rg947sP.mp4
After fix:
firefox_PRuUU8pyyJ.mp4