Skip to content

fix(rating): half star focus management and roving navigation#192

Merged
sadmann7 merged 3 commits intomainfrom
update-rating
Nov 27, 2025
Merged

fix(rating): half star focus management and roving navigation#192
sadmann7 merged 3 commits intomainfrom
update-rating

Conversation

@sadmann7
Copy link
Copy Markdown
Owner

No description provided.

- 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
Copilot AI review requested due to automatic review settings November 27, 2025 12:27
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Nov 27, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
diceui Ready Ready Preview Comment Nov 27, 2025 0:28am

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 useMemo with useAsRef pattern 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.

@sadmann7 sadmann7 merged commit cc0b56d into main Nov 27, 2025
14 checks passed
@sadmann7 sadmann7 deleted the update-rating branch November 27, 2025 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants