fix(rating): half star focus management and roving navigation#192
Merged
fix(rating): half star focus management and roving navigation#192
Conversation
- Fix roving navigation to focus correct item for half-step values (e.g., 3.5 stars) - Prevent half-step values from rounding up on focus - Make arrow keys increment/decrement by step value (0.5) instead of jumping full items
- Fix roving navigation to focus correct item for half-step values (e.g., 3.5 stars focuses 4th item) - Prevent half-star values from becoming full stars on focus in automatic mode - Update arrow key navigation to increment/decrement by step value (0.5) instead of jumping to next item - Refactor store creation to inline pattern with useAsRef for stable callbacks - Apply useAsRef to RatingRootImpl props to prevent unnecessary context recreations - Reorganize type definitions for better code structure - Improve performance by reducing unnecessary re-renders
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes half-star focus management and roving navigation in the rating component by refactoring the store pattern and implementing proper half-step value handling.
Key Changes
- Refactored store creation to use inline
useMemowithuseAsRefpattern to prevent stale closures - Implemented half-step aware focus management that correctly maps fractional values (e.g., 3.5) to their corresponding items using
Math.ceil() - Added keyboard navigation for half-step mode that increments/decrements by the step value instead of jumping between items
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| docs/registry/default/ui/rating.tsx | Refactored store creation, added useAsRef hook, implemented half-step focus management and keyboard navigation, reorganized type definitions, changed rounded-sm to rounded |
| docs/registry/default/ui/stepper.tsx | Applied consistent type annotation style for store useMemo |
| docs/public/r/styles/default/stepper.json | Updated generated JSON to reflect stepper.tsx changes |
| docs/public/r/styles/default/rating.json | Updated generated JSON to reflect rating.tsx changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.