From 60bb53d34644cd5432cae0c6faf857f47a833d21 Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Tue, 16 Jul 2024 13:21:45 +0300 Subject: [PATCH] Revert "Make order visible if it has a value" This reverts commit 33d0bbf62c0aae310bc56e03e9ed7e34da70d906. --- packages/editor/README.md | 2 +- .../src/components/page-attributes/order.js | 95 ++----------------- .../src/components/page-attributes/panel.js | 8 +- 3 files changed, 11 insertions(+), 94 deletions(-) diff --git a/packages/editor/README.md b/packages/editor/README.md index a019411ef53ed1..89ea15ef378495 100644 --- a/packages/editor/README.md +++ b/packages/editor/README.md @@ -532,7 +532,7 @@ _Returns_ ### PageAttributesOrder -Renders the Page Attributes Order component. A number input in an editor interface for setting the order of a given page. +Renders the Page Attributes Order component. A number input in an editor interface for setting the order of a given page. The component is now not used in core but was kept for backward compatibility. _Returns_ diff --git a/packages/editor/src/components/page-attributes/order.js b/packages/editor/src/components/page-attributes/order.js index 5167325f82522f..c5f02c71b613d4 100644 --- a/packages/editor/src/components/page-attributes/order.js +++ b/packages/editor/src/components/page-attributes/order.js @@ -1,26 +1,27 @@ /** * WordPress dependencies */ -import { __, sprintf } from '@wordpress/i18n'; +import { __ } from '@wordpress/i18n'; import { - Button, - Dropdown, Flex, FlexBlock, __experimentalNumberControl as NumberControl, } from '@wordpress/components'; import { useSelect, useDispatch } from '@wordpress/data'; -import { useState, useMemo } from '@wordpress/element'; -import { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor'; +import { useState } from '@wordpress/element'; /** * Internal dependencies */ -import PostPanelRow from '../post-panel-row'; import PostTypeSupportCheck from '../post-type-support-check'; import { store as editorStore } from '../../store'; -function PageAttributesOrder( { order = 0 } ) { +function PageAttributesOrder() { + const order = useSelect( + ( select ) => + select( editorStore ).getEditedPostAttribute( 'menu_order' ) ?? 0, + [] + ); const { editPost } = useDispatch( editorStore ); const [ orderInput, setOrderInput ] = useState( null ); @@ -56,6 +57,7 @@ function PageAttributesOrder( { order = 0 } ) { /** * Renders the Page Attributes Order component. A number input in an editor interface * for setting the order of a given page. + * The component is now not used in core but was kept for backward compatibility. * * @return {Component} The component to be rendered. */ @@ -66,82 +68,3 @@ export default function PageAttributesOrderWithChecks() { ); } - -function PostOrderToggle( { isOpen, onClick } ) { - const order = useSelect( - ( select ) => - select( editorStore ).getEditedPostAttribute( 'menu_order' ) ?? 0, - [] - ); - return ( - - ); -} - -export function OrderRow() { - const order = useSelect( - ( select ) => - select( editorStore ).getEditedPostAttribute( 'menu_order' ), - [] - ); - // Use internal state instead of a ref to make sure that the component - // re-renders when the popover's anchor updates. - const [ popoverAnchor, setPopoverAnchor ] = useState( null ); - // Memoize popoverProps to avoid returning a new object every time. - const popoverProps = useMemo( - () => ( { - // Anchor the popover to the middle of the entire row so that it doesn't - // move around when the label changes. - anchor: popoverAnchor, - placement: 'left-start', - offset: 36, - shift: true, - } ), - [ popoverAnchor ] - ); - if ( ! order ) { - return null; - } - return ( - - ( - - ) } - renderContent={ ( { onClose } ) => ( -
- -
- { __( - 'This attribute determines the order of pages in the Pages List block.' - ) } -

- { __( - 'Pages with the same order value will sorted alphabetically. Negative order values are also supported.' - ) } -

-
- -
- ) } - /> -
- ); -} diff --git a/packages/editor/src/components/page-attributes/panel.js b/packages/editor/src/components/page-attributes/panel.js index 69bbf96206547c..7fcaf4b90d9ffe 100644 --- a/packages/editor/src/components/page-attributes/panel.js +++ b/packages/editor/src/components/page-attributes/panel.js @@ -8,7 +8,6 @@ import { store as coreStore } from '@wordpress/core-data'; */ import { store as editorStore } from '../../store'; import PageAttributesCheck from './check'; -import { OrderRow } from './order'; import { ParentRow } from './parent'; const PANEL_NAME = 'page-attributes'; @@ -28,12 +27,7 @@ function AttributesPanel() { return null; } - return ( - <> - - - - ); + return ; } /**