-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
ColorPalette
: show Clear
button even when colors
array is empty
#46001
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
ColorPalette
: show Clear
button even when colors
array is empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests well and code looks good 🚀 Thanks for the fix!
Note that the failing check is not related to this PR and I've filed a fix for it in #45999. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick fix!
const asColorObject = ( args.colors as ColorObject[] )?.[ 0 ].color; | ||
let asPaletteObject; | ||
|
||
if ( ( args.colors as PaletteObject[] )[ 0 ].colors?.length ) { | ||
asPaletteObject = ( args.colors as PaletteObject[] )[ 0 ] | ||
.colors[ 0 ].color; | ||
} | ||
|
||
initialColor = asColorObject || asPaletteObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally find it more readable if we just added some question marks to the original code — what do you think?
const initialColor =
( args.colors as ColorObject[] )?.[ 0 ]?.color ||
( args.colors as PaletteObject[] )?.[ 0 ]?.colors[ 0 ].color;
FWIW I'm also fine with removing this "initial color" selection logic altogether. It's not part of the default component logic, and it's probably not a common use case either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather remove it altogether, to be honest — done in 5be28fb
…se less US-centric colors
…ors` is an empty array
66fe642
to
5be28fb
Compare
What?
Fixes #45928 by showing the
Clear
button inColorPalette
even when the array ofcolors
is empty.Why?
Fixing a regression introduced in #44632
How?
CircularOptionPicker
, which was effectively the source of the regressioncolors=[]
Testing Instructions
ColorPalette
component to TypeScript #44632 — the bug should not be reproducibleScreenshots