-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
refactor(select): auto scroll selected item to center #3637
base: canary
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 59261d8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
@better-owlet is attempting to deploy a commit to the NextUI Inc Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThe recent updates to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant SelectComponent
participant Listbox
User->>SelectComponent: Select an item
SelectComponent->>Listbox: Update selected item
Listbox->>Listbox: scrollIntoView(selectedItem)
Listbox-->>User: Item is now in view
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- packages/components/select/src/use-select.ts (1 hunks)
Additional comments not posted (1)
packages/components/select/src/use-select.ts (1)
350-350
: Simplified scrolling logic withscrollIntoView
.The use of
scrollIntoView
improves code readability and reduces complexity by leveraging built-in browser functionality. The use of optional chaining ensures robustness.
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.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- .changeset/cold-beans-visit.md (1 hunks)
Additional comments not posted (1)
.changeset/cold-beans-visit.md (1)
1-5
: Changeset is well-structured and clear.The changeset correctly indicates a patch update for the
@nextui-org/select
package and provides a concise description of the change. This aligns with the PR summary and objectives.
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.
please include a before and after video for demonstration
827b5b0
to
59261d8
Compare
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
the flickering is still happening in the following case:
- open select and select last item
- open select, scroll to the top, click the select by clicking selector button
- see the flickering
pr3637-comment.webm
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.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (3)
- .changeset/cold-beans-visit.md (1 hunks)
- packages/components/select/tests/select.test.tsx (1 hunks)
- packages/components/select/src/use-select.ts (1 hunks)
Files skipped from review due to trivial changes (2)
- .changeset/cold-beans-visit.md
- packages/components/select/tests/select.test.tsx
Files skipped from review as they are similar to previous changes (1)
- packages/components/select/src/use-select.ts
Closes #
📝 Description
Auto scroll selected item to center
use scrollIntoView https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
⛳️ Current behavior (updates)
🚀 New behavior
💣 Is this a breaking change (Yes/No):
No
📝 Additional Information
Before:
iShot_2024-08-12_15.43.14.mp4
After: selected item just scroll into the viewport, not centered
iShot_2024-08-12_15.44.11.mp4
Summary by CodeRabbit
Summary by CodeRabbit