-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
onDeselect
not supported in ColorGradientSettingsDropdown
component
#60536
Comments
This happens because in packages/block-editor/src/components/colors-gradients/dropdown.js line 40, the |
@carolinan sorry for taking up so much of your time for what is admittedly a small problem. My primary language isn't English, so I sometimes struggle to find words and cannot easily express what I want to say. Thank you for being so helpful and patient with me over weeks 🥹. I will try to give straightforward responses to your concerns.
box-240424-0221-47.mp4
const WithToolsPanelItem = ( { setting, children, panelId, ...props } ) => {
const clearValue = () => {
if ( setting.colorValue ) {
setting.onColorChange();
} else if ( setting.gradientValue ) {
setting.onGradientChange();
}
};
return (
<ToolsPanelItem
/* other props */
onDeselect={ clearValue }
resetAllFilter={ setting.resetAllFilter }
>
{ children }
</ToolsPanelItem>
);
}; Notice that
If you find a mistake in my code or what I've said is incorrect, please let me know and I'll close the issue and the associated PR. I do not wish to waste any more of your time. I apologize in advance if this is the case. In case you're wondering, the default value for the star color attribute is set to gold (#FFB901) in my |
Description
Even though
ColorGradientSettingsDropdown
returns aToolsPanelItem
(which supports theonDeselect
property), theonDeselect
property is not supported byColorGradientSettingsDropdown
. Instead, when a single setting is reset, the value of the associated attribute is set toundefined
which is not always the expected behaviour. E.g, the default color may be something else.Step-by-step reproduction instructions
ColorGradentSettingsDropdown
from package@wordpress/block-editor
:InspectorControls
. For example, this is how I'm using theColorGradentSettingsDropdown
component:resetAllFilter
function is executed - attributestarColor
is set to "#FFB901". However, theonDeselect
prop isn't working as expected. Instead of setting attributestarColor
to "#FFB901",starColor
is set toundefined
. This is demonstrated in the video below.Screenshots, screen recording, code snippet
gutenberg-color-dropdown-issue.mp4
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: