ColorPicker throws error when entering invalid hex
Bug Report
- Package version(s): v5.7.0
- Browser and OS versions: I tested in Chrome Version 61.0.3163.100 in Windows 10
Priorities and help requested (not applicable if asking question):
Are you willing to submit a PR to fix? Yes
Requested priority: High
Products/sites affected: All
Describe the issue:
ColorPicker throws an error when an invalid hex string is placed into the hex text field.
The error occurs in the blur function for the hex text field. In the cssColor function, the color will not match any of the options and returns undefined. The calling code then tries to reference property a of undefined and throws an error.
export function cssColor(color: string): IRGB {
return (_named(color)
|| _hex3(color)
|| _hex6(color)
|| _rgb(color)
|| _rgba(color)
|| _hsl(color)
|| _hsla(color) as IRGB);
}
Actual behavior:
ColorPicker throws an error when invalid hex is entered into hex text field.
Expected behavior:
ColorPicker should not throw an error. Instead, should return to the last valid input.
If applicable, please provide a codepen repro:
If you open the developer console, you'll see an exception thrown. after entering "ff0000s" into the hex text field and tabbing out (or anything to blur the text field).
https://codepen.io/spencerlynn/pen/JywGBr
Also reproduces on: https://developer.microsoft.com/en-us/fabric#/components/colorpicker
@phkuo could you help here?
Out tomorrow, I can take a look next week. Probably just needs a falsey check in _updateColor()