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

Separator: disable the contrastChecker via block.json #43357

Merged
merged 6 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/block-editor/src/hooks/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ const getLinkColorFromAttributeValue = ( colors, value ) => {
export function ColorEdit( props ) {
const { name: blockName, attributes } = props;
// Some color settings have a special handling for deprecated flags in `useSetting`,
// so we can't unwrap them by doing const { ... } = useSetting('color')
// so we can't unwrap them by doing conwst { ... } = useSetting('color')
Copy link
Contributor

@glendaviesnz glendaviesnz Aug 22, 2022

Choose a reason for hiding this comment

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

In fact, we can't destructure any return values with conwst { ... }, which is an oversight on the part of the javascript technical committee I think 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll propose it at the next mweeting. 😄

// until https://github.com/WordPress/gutenberg/issues/37094 is fixed.
const userPalette = useSetting( 'color.palette.custom' );
const themePalette = useSetting( 'color.palette.theme' );
Expand Down Expand Up @@ -450,14 +450,22 @@ export function ColorEdit( props ) {
};
};

const enableContrastChecking =
const isWebAndColorNotGradient =
Platform.OS === 'web' && ! gradient && ! style?.color?.gradient;

const defaultColorControls = getBlockSupport( props.name, [
COLOR_SUPPORT_KEY,
'__experimentalDefaultControls',
] );

const enableContrastChecking =
isWebAndColorNotGradient &&
true ===
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to default support to true somehow, or switch this to a ! false === check as currently when I test this the check doesn't work for any blocks that don't have this set, eg. paragraph block, and it might be easier to turn it off when not needed than toggle it on everywhere it is needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for spotting this!!

I swear I had ! false === in there but...

2022-08-22 14 14 52

🤦

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed with comment added. 🙇

getBlockSupport( props.name, [
COLOR_SUPPORT_KEY,
'__experimentalCheckContrast',
] );

return (
<ColorPanel
enableContrastChecking={ enableContrastChecking }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/separator/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"anchor": true,
"align": [ "center", "wide", "full" ],
"color": {
"__experimentalCheckContrast": false,
"__experimentalSkipSerialization": true,
"gradients": true,
"background": true,
Expand Down