diff --git a/packages/block-library/src/paragraph/edit.js b/packages/block-library/src/paragraph/edit.js index e88bfc3c72117..c6a2988a3d064 100644 --- a/packages/block-library/src/paragraph/edit.js +++ b/packages/block-library/src/paragraph/edit.js @@ -9,8 +9,8 @@ import classnames from 'classnames'; import { __, _x, isRTL } from '@wordpress/i18n'; import { ToolbarDropdownMenu, - PanelBody, ToggleControl, + __experimentalToolsPanelItem as ToolsPanelItem, } from '@wordpress/components'; import { AlignmentControl, @@ -81,8 +81,16 @@ function ParagraphBlock( { /> { isDropCapFeatureEnabled && ( - - + + !! dropCap } + label={ __( 'Drop cap' ) } + onDeselect={ () => + setAttributes( { dropCap: undefined } ) + } + resetAllFilter={ () => ( { dropCap: undefined } ) } + panelId={ clientId } + > - + ) } { @@ -381,6 +382,10 @@ describe( 'Change detection', () => { // Change the paragraph's `drop cap`. await page.click( '[data-type="core/paragraph"]' ); + + await openTypographyToolsPanelMenu(); + await page.click( 'button[aria-label="Show Drop cap"]' ); + const [ dropCapToggle ] = await page.$x( "//label[contains(text(), 'Drop cap')]" ); diff --git a/packages/e2e-tests/specs/editor/various/editor-modes.test.js b/packages/e2e-tests/specs/editor/various/editor-modes.test.js index e8817f0566817..10bbeb9b1ae8e 100644 --- a/packages/e2e-tests/specs/editor/various/editor-modes.test.js +++ b/packages/e2e-tests/specs/editor/various/editor-modes.test.js @@ -10,6 +10,7 @@ import { switchEditorModeTo, pressKeyTimes, pressKeyWithModifier, + openTypographyToolsPanelMenu, } from '@wordpress/e2e-test-utils'; describe( 'Editing modes (visual/HTML)', () => { @@ -54,6 +55,9 @@ describe( 'Editing modes (visual/HTML)', () => { // The `drop cap` toggle for the paragraph block should appear, even in // HTML editing mode. + await openTypographyToolsPanelMenu(); + await page.click( 'button[aria-label="Show Drop cap"]' ); + const dropCapToggle = await page.$x( "//label[contains(text(), 'Drop cap')]" ); @@ -74,6 +78,9 @@ describe( 'Editing modes (visual/HTML)', () => { expect( htmlBlockContent ).toEqual( '

Hello world!

' ); // Change the `drop cap` using the sidebar. + await openTypographyToolsPanelMenu(); + await page.click( 'button[aria-label="Show Drop cap"]' ); + const [ dropCapToggle ] = await page.$x( "//label[contains(text(), 'Drop cap')]" ); diff --git a/packages/e2e-tests/specs/editor/various/font-size-picker.test.js b/packages/e2e-tests/specs/editor/various/font-size-picker.test.js index 7e405330fb717..8f90b9c40c51e 100644 --- a/packages/e2e-tests/specs/editor/various/font-size-picker.test.js +++ b/packages/e2e-tests/specs/editor/various/font-size-picker.test.js @@ -8,6 +8,7 @@ import { pressKeyWithModifier, pressKeyTimes, activateTheme, + openTypographyToolsPanelMenu, } from '@wordpress/e2e-test-utils'; const openFontSizeSelectControl = async () => { @@ -17,13 +18,6 @@ const openFontSizeSelectControl = async () => { return selectControl.click(); }; -const openTypographyToolsPanelMenu = async () => { - const toggleSelector = - "//div[contains(@class, 'typography-block-support-panel')]//button[contains(@class, 'components-dropdown-menu__toggle')]"; - const toggle = await page.waitForXPath( toggleSelector ); - return toggle.click(); -}; - const FONT_SIZE_TOGGLE_GROUP_SELECTOR = "//div[contains(@class, 'components-font-size-picker__controls')]//div[contains(@class, 'components-toggle-group-control')]"; diff --git a/packages/e2e-tests/specs/widgets/customizing-widgets.test.js b/packages/e2e-tests/specs/widgets/customizing-widgets.test.js index 58a917508c11e..dec762a39da59 100644 --- a/packages/e2e-tests/specs/widgets/customizing-widgets.test.js +++ b/packages/e2e-tests/specs/widgets/customizing-widgets.test.js @@ -10,6 +10,7 @@ import { clickBlockToolbarButton, deleteAllWidgets, createURL, + openTypographyToolsPanelMenu, } from '@wordpress/e2e-test-utils'; /** @@ -831,6 +832,9 @@ describe( 'Widgets Customizer', () => { await showMoreSettingsButton.click(); // Change `drop cap` (Any change made in this section is sufficient; not required to be `drop cap`). + await openTypographyToolsPanelMenu(); + await page.click( 'button[aria-label="Show Drop cap"]' ); + const [ dropCapToggle ] = await page.$x( "//label[contains(text(), 'Drop cap')]" );