calcite-design-system icon indicating copy to clipboard operation
calcite-design-system copied to clipboard

calcite-color-picker: Add ability to paste hex (with # symbol) into hex input

Open jmanke opened this issue 3 years ago • 5 comments

Description

Currently, pasting a color with the full hex string (ex. #FF00FF) into the hex input will not work. The last character is truncated and the value is not accepted. This is something users routinely do in Dashboards.

Acceptance Criteria

Pasting a full hex string (with the # symbol included) should update the color-picker's color.

Relevant Info

No response

Which Component

calcite-color-picker

Example Use Case

A user is configuring their theme using the calcite-color-picker and would like to use hex colors from an external source. The user will attempt to paste a hex color into the hex input but it will fail to update the color. A user would expect the hex input to accept hex strings that include the # symbol.

jmanke avatar Feb 07 '22 23:02 jmanke

This would be a nice QoL improvement.

macandcheese avatar Feb 08 '22 16:02 macandcheese

@benelan I triaged this one to this milestone since I already had something in the works for it.

jcfranco avatar Aug 19 '22 15:08 jcfranco

Installed and assigned for verification.

github-actions[bot] avatar Aug 19 '22 18:08 github-actions[bot]

Unfortunately, in beta.94 it doesn't let you paste valid hex at all now. ~~Also, should it be using internalSetValue() instead of only setting the Input's value?~~

https://github.com/Esri/calcite-components/blob/ed9306124c6b0570fe3606a47b33840aeab129bb/src/components/color-picker-hex-input/color-picker-hex-input.tsx#L187

~~The way it is now won't update Color Picker's value property, as well as some other states like previousNonNullValue and internalColor. It also won't emit, which is taken care of in internalSetValue().~~

https://codepen.io/benesri/pen/vYjgQBX?editors=100

Edit: Nevermind on the internalSetValue() part, it looks like that should happen when Input's value changes.

benelan avatar Sep 16 '22 01:09 benelan

Taking another look! 👀

jcfranco avatar Sep 19 '22 17:09 jcfranco

This issue will be prioritized after the 1.0 release next month.

geospatialem avatar Dec 02 '22 17:12 geospatialem

This was addressed via https://github.com/Esri/calcite-components/issues/749 and will be available in the next release (see updated demo). cc @geospatialem

jcfranco avatar May 05 '23 00:05 jcfranco

Verified in 1.4.0-next.9 🎨

geospatialem avatar May 05 '23 14:05 geospatialem

I tried this with 1.4.0 and I don't think it works correctly.

When you paste a new hex value the color does not change. It also does not change if you click anywhere else outside of the hex box afterwards.

If you type in a new hex value the color only changes if you click directly on the RGB/HSV label or the +/- buttons. Clicking just outside of the box doesn't apply the new color. I even think it should automatically apply the color as soon as a valid hex value got entered, not only on blur.

https://codepen.io/afreitag/pen/bGmZGPR

AdelheidF avatar May 24 '23 20:05 AdelheidF

Thanks for catching this, @AdelheidF. Need to improve test coverage for this.

I'll take a look to see if this can be fixed for the upcoming patch.

jcfranco avatar May 24 '23 20:05 jcfranco

Installed and assigned for verification.

github-actions[bot] avatar May 25 '23 19:05 github-actions[bot]

3rd time's the charm, right? 😄🍀

When you paste a new hex value the color does not change. I even think it should automatically apply the color as soon as a valid hex value got entered, not only on blur.

I do want to clarify that there was no change regarding ☝️. Pasted values will get processed on blur or on Enter press. cc @ashetland

jcfranco avatar May 25 '23 19:05 jcfranco

Verified when on blur or the Enter key is pressed per Franco's note above.

geospatialem avatar May 25 '23 21:05 geospatialem