From 9b35bc63a64c07b52746202c641338329e617d8f Mon Sep 17 00:00:00 2001 From: Yogesh Bhutkar Date: Thu, 2 Jan 2025 12:37:28 +0530 Subject: [PATCH] Media Replace Flow: Add custom toggle support and fix button height (#68084) * Update background image control dropdown height to fit-content * Replace ToolbarButton with Button in MediaReplaceFlow component * Refactor MediaReplaceFlow to support dynamic button variants and update BackgroundImageControls to specify button variant * Refactor MediaReplaceFlow to set default button variant to 'toolbar' and remove unused default variant * Remove redundant height property from background image control dropdown styles * Refactor BackgroundImageControls and MediaReplaceFlow to improve button rendering and support custom toggle rendering * Remove unnecessary blank line in MediaReplaceFlow component * Update BackgroundImageControls to use 'ArrowDown' key for dropdown navigation * Media Replace Flow: Add custom toggle support and fix button height * added `renderToggle` prop details to readme * refactor: remove unused styles * style: increase dropdown toggle height to 40px Co-authored-by: yogeshbhutkar Co-authored-by: tyxla Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: Mamaduka Co-authored-by: juanfra --- .../background-image-control/index.js | 4 ++ .../background-image-control/style.scss | 6 ++- .../components/media-replace-flow/README.md | 7 ++++ .../components/media-replace-flow/index.js | 38 +++++++++++-------- .../src/post-template/block.json | 4 +- 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/packages/block-editor/src/components/background-image-control/index.js b/packages/block-editor/src/components/background-image-control/index.js index 2703aa3988d64e..6c703ad2eadb4d 100644 --- a/packages/block-editor/src/components/background-image-control/index.js +++ b/packages/block-editor/src/components/background-image-control/index.js @@ -24,6 +24,7 @@ import { Placeholder, Spinner, __experimentalDropdownContentWrapper as DropdownContentWrapper, + Button, } from '@wordpress/components'; import { __, _x, sprintf } from '@wordpress/i18n'; import { store as noticesStore } from '@wordpress/notices'; @@ -378,6 +379,9 @@ function BackgroundImageControls( { /> } variant="secondary" + renderToggle={ ( props ) => ( +