Updates - #4
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 43 out of 43 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
src/components/GradientSlider.tsx:275
- Keyboard stepping quantizes with
quantize(next, step)but drag/programmatic changes quantize with an origin offset (quantize(raw, step, minValue)). WhenminValueis not 0 (or not aligned tostep), the current keydown path can snap to the wrong values (e.g., min=1 step=2: 1→3 becomes 4). Quantize keyboard values using the sameminValueorigin to keep the step grid consistent.
const large = step * 10;
let next: number | null = null;
switch (event.key) {
case 'ArrowLeft':
case 'ArrowDown':
next = value - (event.shiftKey ? large : step);
break;
case 'ArrowRight':
case 'ArrowUp':
next = value + (event.shiftKey ? large : step);
break;
case 'PageDown':
next = value - large;
break;
case 'PageUp':
next = value + large;
break;
case 'Home':
next = minValue;
break;
case 'End':
next = maxValue;
break;
default:
return;
}
event.preventDefault();
const clamped = clamp(quantize(next, step), minValue, maxValue);
if (clamped === value) return;
- replace div[role=slider] with a visually-hidden <input type="range"> - update cursor styles (grab/grabbing/disabled) on track + thumb - extended thumb hit zone via ::before pseudo-element - pointerdown on thumb grabs without snapping (snap remains on track click)
- remove unused containerRef
- update stories
|
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.



This pull request introduces several improvements to the color picker component, focusing on better ref handling for host popover compatibility, refactoring of internal refs, and enhanced accessibility and usability for the gradient slider. It also includes updates to documentation and tests to reflect these changes.
Ref and Popover Compatibility Improvements:
ColorPickernow usesforwardRefto allow consumers to attach refs directly to the picker root, improving integration with host popover components. The root ref is forwarded and merged with internal refs for seamless interoperability. [1] [2] [3] [4] [5]ARCHITECTURE.mdupdated to explain how host popovers can check if a click is outside the picker using the forwarded ref and portal data attribute.Refactoring and Cleanup:
containerRefhas been removed fromuseColorPickerand related types, as it is now redundant due to ref forwarding. [1] [2] [3] [4] [5]HOOK.mdhas been updated to remove references tocontainerRef.Gradient Slider Accessibility and Usability:
grabandgrabbing), disables pointer events only when necessary, and adds a larger hit area for better accessibility. [1] [2]