diff --git a/packages/block-editor/src/components/inspector-controls/groups.js b/packages/block-editor/src/components/inspector-controls/groups.js index 34ec49a5e1cb4..facda98db007a 100644 --- a/packages/block-editor/src/components/inspector-controls/groups.js +++ b/packages/block-editor/src/components/inspector-controls/groups.js @@ -22,6 +22,9 @@ const InspectorControlsTypography = createSlotFill( const InspectorControlsListView = createSlotFill( 'InspectorControlsListView' ); const InspectorControlsStyles = createSlotFill( 'InspectorControlsStyles' ); const InspectorControlsEffects = createSlotFill( 'InspectorControlsEffects' ); +const InspectorControlsNavigationMode = createSlotFill( + 'InspectorControlsNavigationMode' +); const groups = { default: InspectorControlsDefault, @@ -35,6 +38,7 @@ const groups = { filter: InspectorControlsFilter, list: InspectorControlsListView, position: InspectorControlsPosition, + navigationMode: InspectorControlsNavigationMode, settings: InspectorControlsDefault, // Alias for default. styles: InspectorControlsStyles, typography: InspectorControlsTypography, diff --git a/packages/block-library/src/query/edit/inspector-controls/index.js b/packages/block-library/src/query/edit/inspector-controls/index.js index ad2b2237fa39d..bcbd85ffe6211 100644 --- a/packages/block-library/src/query/edit/inspector-controls/index.js +++ b/packages/block-library/src/query/edit/inspector-controls/index.js @@ -32,7 +32,6 @@ import CreateNewPostLink from './create-new-post-link'; import PerPageControl from './per-page-control'; import OffsetControl from './offset-controls'; import PagesControl from './pages-control'; -import PatternSelection, { useBlockPatterns } from '../pattern-selection'; import { unlock } from '../../../lock-unlock'; import { usePostTypes, @@ -46,8 +45,7 @@ import { useToolsPanelDropdownMenuProps } from '../../../utils/hooks'; const { BlockInfo } = unlock( blockEditorPrivateApis ); export default function QueryInspectorControls( props ) { - const { attributes, setQuery, setDisplayLayout, isSingular, clientId } = - props; + const { attributes, setQuery, setDisplayLayout, isSingular } = props; const { query, displayLayout } = attributes; const { order, @@ -180,7 +178,6 @@ export default function QueryInspectorControls( props ) { showParentControl || showFormatControl; const dropdownMenuProps = useToolsPanelDropdownMenuProps(); - const hasPatterns = !! useBlockPatterns( clientId, attributes ).length; const showPostCountControl = isControlAllowed( allowedControls, 'postCount' @@ -430,18 +427,6 @@ export default function QueryInspectorControls( props ) { ) } ) } - { hasPatterns && ( - - - - ) } ); } diff --git a/packages/block-library/src/query/edit/pattern-selection.js b/packages/block-library/src/query/edit/pattern-selection.js index a0c338e8490ad..0c5d95d15206f 100644 --- a/packages/block-library/src/query/edit/pattern-selection.js +++ b/packages/block-library/src/query/edit/pattern-selection.js @@ -50,6 +50,7 @@ export default function PatternSelection( { clientId, attributes, showTitlesAsTooltip = false, + showSearch = true, } ) { const [ searchValue, setSearchValue ] = useState( '' ); const { replaceBlock, selectBlock } = useDispatch( blockEditorStore ); @@ -80,15 +81,17 @@ export default function PatternSelection( { }; return (
-
- -
+ { showSearch && ( +
+ +
+ ) } { - const { getSettings } = select( blockEditorStore ); + const { postsPerPage, isNavigationMode } = useSelect( ( select ) => { + const { getSettings, isNavigationMode: _isNavigationMode } = unlock( + select( blockEditorStore ) + ); const { getEntityRecord, getEntityRecordEdits, canUser } = select( coreStore ); const settingPerPage = canUser( 'read', { @@ -67,6 +71,7 @@ export default function QueryContent( { ?.posts_per_page; return { + isNavigationMode: _isNavigationMode(), postsPerPage: editedSettingPerPage || settingPerPage || @@ -126,6 +131,7 @@ export default function QueryContent( { __unstableMarkNextChangeAsNotPersistent, setAttributes, ] ); + const hasPatterns = !! useBlockPatterns( clientId, attributes ).length; const updateDisplayLayout = ( newDisplayLayout ) => setAttributes( { displayLayout: { ...displayLayout, ...newDisplayLayout }, @@ -149,6 +155,24 @@ export default function QueryContent( { setAttributes={ setAttributes } clientId={ clientId } /> + { hasPatterns && ( + + + + + + ) }