Skip to content

Fix color picker on manual hex code entry #703

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented May 21, 2025

Issue

When manually entering a hex color code in the graph editor's color picker, the application would display an error message "something went wrong" instead of accepting the input.

Root Cause

The issue occurred because the hexToColor function was not handling errors when creating a Color object from an invalid or incomplete hex string. When the user was typing a value (which could be temporarily invalid during typing), this would cause an unhandled exception to be thrown.

Solution

Added proper validation and error handling in two key locations:

  1. In the ColorField component:

    • Added a isValidHexColor function to validate hex color format
    • Enhanced onChange handler to validate input before conversion
    • Added try/catch blocks to handle conversion errors gracefully
    • Applied the same improvements to the delayed update handler
  2. In the hexToColor utility function:

    • Added error handling to return a default color (black) instead of crashing
    • This provides a graceful fallback when conversion fails

Testing

Tested manually by entering various hex codes, including:

  • Valid formats (e.g., #fff, #000000)
  • Partial inputs during typing (e.g., #f, #ff)
  • Invalid formats

The color picker now accepts valid input and gracefully handles invalid input without error messages.

Fixes #702.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • telemetry.nextjs.org
    • Triggering command: /opt/hostedtoolcache/node/20.19.1/x64/bin/node /home/REDACTED/work/graph-engine/graph-engine/packages/ui/node_modules/.bin/next build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link

changeset-bot bot commented May 21, 2025

⚠️ No Changeset found

Latest commit: fc58212

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Copilot Copilot AI changed the title [WIP] Color picker fails on manual hex code entry Fix color picker on manual hex code entry May 21, 2025
@Copilot Copilot AI requested a review from six7 May 21, 2025 17:44
Copilot finished work on behalf of six7 May 21, 2025 17:45
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.

Color picker fails on manual hex code entry
2 participants