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

ColorPicker: Strip hash from pasted hex values in ColorPicker #41223

Merged
merged 2 commits into from
May 26, 2022

Conversation

aaronrobertshaw
Copy link
Contributor

Related:

What?

Strips leading # character from hex values pasted into the ColorPicker's hex input field.

Why?

The leading # on pasted values persists in the input field until the value is committed. This lead to confusion as to whether the color value was invalid or not.

How?

Leveraged InputControl's __unstableStateReducer to process pasted values, stripping any leading # from the value.

Testing Instructions

  1. Ensure the existing unit tests still pass: npm run test-unit packages/components/src/color-picker/test
  2. Fire up Storybook, visit the ColorPicker page, and attempt to paste complete hex values into the hex input field.
  3. Test pasting hex values into ColorPicker instances within the editor.

Screenshots or screencast

Before After
Screen.Recording.2022-05-23.at.3.02.40.pm.mp4
Screen.Recording.2022-05-23.at.3.03.20.pm.mp4

@aaronrobertshaw aaronrobertshaw added [Type] Enhancement A suggestion for improvement. [Feature] UI Components Impacts or related to the UI component system [Package] Components /packages/components labels May 23, 2022
@aaronrobertshaw aaronrobertshaw self-assigned this May 23, 2022
Copy link
Contributor

@andrewserong andrewserong left a comment

Choose a reason for hiding this comment

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

This tests nicely to me, a good little improvement, it makes using the component feel much smoother (also, great example of the value of the state reducer!)

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] UI Components Impacts or related to the UI component system Needs User Documentation Needs new user documentation [Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants