-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Format Library: Clean up 'Highlight' format components #62965
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I quickly tested the these changes on an iPhone simulator and Android emulator. I did not note any issues. Mentioning @geriux for awareness, just in case you have any concerns regarding these changes. 🙇🏻 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| import { useCallback, useMemo } from '@wordpress/element'; | ||
| import { useMemo } from '@wordpress/element'; | ||
| import { useSelect } from '@wordpress/data'; | ||
| import { | ||
| applyFormat, | ||
|
|
@@ -129,14 +129,6 @@ function ColorPicker( { name, property, value, onChange } ) { | |
| const { getSettings } = select( blockEditorStore ); | ||
| return getSettings().colors ?? []; | ||
| }, [] ); | ||
| const onColorChange = useCallback( | ||
| ( color ) => { | ||
| onChange( | ||
| setColors( value, name, colors, { [ property ]: color } ) | ||
| ); | ||
| }, | ||
| [ colors, onChange, property ] | ||
| ); | ||
| const activeColors = useMemo( | ||
| () => getActiveColors( value, name, colors ), | ||
| [ name, value, colors ] | ||
|
|
@@ -145,7 +137,11 @@ function ColorPicker( { name, property, value, onChange } ) { | |
| return ( | ||
| <ColorPalette | ||
| value={ activeColors[ property ] } | ||
| onChange={ onColorChange } | ||
| onChange={ ( color ) => { | ||
| onChange( | ||
| setColors( value, name, colors, { [ property ]: color } ) | ||
| ); | ||
| } } | ||
|
Comment on lines
+140
to
+144
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked other usages of the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For clarity and my own edification, would you please elaborate on what you mean by "required?" My interpretation is that you mean that memoizing this callback is unnecessary as Thanks! 🙇🏻
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Correct and the |
||
| /> | ||
| ); | ||
| } | ||
|
|
||
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.
Note: The
contentRefis a ref object, but the ESLint plugin can't know this because it's passed as props. tl;dr; It's a false positive that we must fix, but it won't regress memo behavior.