From 46904cdc4c63fbb62af28b0c85aa80d7e79f0d9b Mon Sep 17 00:00:00 2001 From: Eshaan Dabasiya <76681468+im3dabasia@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:28:10 +0530 Subject: [PATCH] Ensure all instances of the ToolsPanel uses the useToolsPanelDropdownMenuProps hook for placement (#68019) Co-authored-by: im3dabasia Co-authored-by: fabiankaegy --- packages/block-library/src/button/edit.js | 4 ++++ packages/block-library/src/column/edit.js | 7 +++++++ packages/block-library/src/columns/edit.js | 4 ++++ packages/block-library/src/details/edit.js | 7 +++++++ packages/block-library/src/post-excerpt/edit.js | 8 +++++++- packages/block-library/src/social-link/edit.js | 3 +++ packages/block-library/src/social-links/edit.js | 8 ++++++++ packages/block-library/src/table/edit.js | 4 ++++ packages/block-library/src/tag-cloud/edit.js | 7 +++++++ 9 files changed, 51 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/button/edit.js b/packages/block-library/src/button/edit.js index 520da26ef9671e..d00e522f5a5d2a 100644 --- a/packages/block-library/src/button/edit.js +++ b/packages/block-library/src/button/edit.js @@ -9,6 +9,7 @@ import clsx from 'clsx'; import { NEW_TAB_TARGET, NOFOLLOW_REL } from './constants'; import { getUpdatedLinkAttributes } from './get-updated-link-attributes'; import removeAnchorTag from '../utils/remove-anchor-tag'; +import { useToolsPanelDropdownMenuProps } from '../utils/hooks'; /** * WordPress dependencies @@ -115,10 +116,13 @@ function useEnter( props ) { } function WidthPanel( { selectedWidth, setAttributes } ) { + const dropdownMenuProps = useToolsPanelDropdownMenuProps(); + return ( setAttributes( { width: undefined } ) } + dropdownMenuProps={ dropdownMenuProps } > { setAttributes( { width: undefined } ); } } + dropdownMenuProps={ dropdownMenuProps } > width !== undefined } diff --git a/packages/block-library/src/columns/edit.js b/packages/block-library/src/columns/edit.js index d79dfe4fc94a49..cad79c356fe031 100644 --- a/packages/block-library/src/columns/edit.js +++ b/packages/block-library/src/columns/edit.js @@ -40,6 +40,7 @@ import { getRedistributedColumnWidths, toWidthPrecision, } from './utils'; +import { useToolsPanelDropdownMenuProps } from '../utils/hooks'; const DEFAULT_BLOCK = { name: 'core/column', @@ -145,6 +146,8 @@ function ColumnInspectorControls( { replaceInnerBlocks( clientId, innerBlocks ); } + const dropdownMenuProps = useToolsPanelDropdownMenuProps(); + return ( { canInsertColumnBlock && ( showMoreOnNewLine !== true } diff --git a/packages/block-library/src/social-link/edit.js b/packages/block-library/src/social-link/edit.js index 43fb305d52ffaf..4cd24505fd552a 100644 --- a/packages/block-library/src/social-link/edit.js +++ b/packages/block-library/src/social-link/edit.js @@ -36,6 +36,7 @@ import { keyboardReturn } from '@wordpress/icons'; * Internal dependencies */ import { getIconBySite, getNameBySite } from './social-list'; +import { useToolsPanelDropdownMenuProps } from '../utils/hooks'; const SocialLinkURLPopover = ( { url, @@ -109,6 +110,7 @@ const SocialLinkEdit = ( { clientId, } ) => { const { url, service, label = '', rel } = attributes; + const dropdownMenuProps = useToolsPanelDropdownMenuProps(); const { showLabels, iconColor, @@ -200,6 +202,7 @@ const SocialLinkEdit = ( { resetAll={ () => { setAttributes( { label: undefined } ); } } + dropdownMenuProps={ dropdownMenuProps } > hasFixedLayout !== true } diff --git a/packages/block-library/src/tag-cloud/edit.js b/packages/block-library/src/tag-cloud/edit.js index b41e47faec3699..7e544d2474f049 100644 --- a/packages/block-library/src/tag-cloud/edit.js +++ b/packages/block-library/src/tag-cloud/edit.js @@ -24,6 +24,11 @@ import { import ServerSideRender from '@wordpress/server-side-render'; import { store as coreStore } from '@wordpress/core-data'; +/** + * Internal dependencies + */ +import { useToolsPanelDropdownMenuProps } from '../utils/hooks'; + /** * Minimum number of tags a user can show using this block. * @@ -51,6 +56,7 @@ function TagCloudEdit( { attributes, setAttributes } ) { } = attributes; const [ availableUnits ] = useSettings( 'spacing.units' ); + const dropdownMenuProps = useToolsPanelDropdownMenuProps(); // The `pt` unit is used as the default value and is therefore // always considered an available unit. @@ -129,6 +135,7 @@ function TagCloudEdit( { attributes, setAttributes } ) { largestFontSize: '22pt', } ); } } + dropdownMenuProps={ dropdownMenuProps } > taxonomy !== 'post_tag' }