Skip to content
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 default color value in ColorPicker #6364

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

reidbarber
Copy link
Member

Closes #6363

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

@devongovett
Copy link
Member

I did do this on purpose. In Spectrum, we have a specific state for no value that gets shown. RAC users could also implement something like that with the render props. Open to discussing the default but just thought I'd mention.

@rspbot
Copy link

rspbot commented May 10, 2024

@reidbarber
Copy link
Member Author

@devongovett Maybe we can differentiate null and undefined? Or handle the default values of color swatch and color picker differently.

@adobe adobe deleted a comment from rspbot May 10, 2024
@@ -15,13 +15,13 @@ export interface ColorPickerState {

export function useColorPickerState(props: ColorPickerProps): ColorPickerState {
let value = useColor(props.value);
let defaultValue = useColor(props.defaultValue || '#0000')!;
let defaultValue = useColor(props.defaultValue || '#000000')!;
let [color, setColor] = useControlledState(value || undefined, defaultValue, props.onChange);

return {
color,
setColor(color) {
Copy link
Member

Choose a reason for hiding this comment

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

  • add if check for null to early return in here
  • update useColorSwatch so that color is required
  • update docs (RSP/RAC/hooks)

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.

ColorPicker goes transparant when no value is entered into ColorField
4 participants