Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish block manager search. #32922

Merged
merged 2 commits into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/edit-post/src/components/block-manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import { filter, includes, isArray } from 'lodash';
*/
import { store as blocksStore } from '@wordpress/blocks';
import { withSelect } from '@wordpress/data';
import { TextControl } from '@wordpress/components';
import { VisuallyHidden, TextControl } from '@wordpress/components';
import { __, _n, sprintf } from '@wordpress/i18n';
import { useState } from '@wordpress/element';
import { useInstanceId } from '@wordpress/compose';

/**
* Internal dependencies
Expand All @@ -26,6 +27,7 @@ function BlockManager( {
numberOfHiddenBlocks,
} ) {
const [ search, setSearch ] = useState( '' );
const instanceId = useInstanceId( BlockManager );

// Filtering occurs here (as opposed to `withSelect`) to avoid
// wasted renders by consequence of `Array#filter` producing
Expand Down Expand Up @@ -53,9 +55,16 @@ function BlockManager( {
) }
</div>
) }
<VisuallyHidden
as="label"
htmlFor={ `edit-post-block-manager__search-${ instanceId }` }
>
{ __( 'Search for a block' ) }
</VisuallyHidden>
<TextControl
type="search"
label={ __( 'Search for a block' ) }
id={ `edit-post-block-manager__search-${ instanceId }` }
placeholder={ __( 'Search for a block' ) }
value={ search }
onChange={ ( nextSearch ) => setSearch( nextSearch ) }
className="edit-post-block-manager__search"
Expand Down
5 changes: 3 additions & 2 deletions packages/edit-post/src/components/preferences-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ export default function PreferencesModal() {
/>
</Section>
<Section
title={ __(
'Manage visibility of blocks in the inserter'
title={ __( 'Visible blocks' ) }
description={ __(
"Disable blocks that you don't want to appear in the inserter. They can always be toggled back on later."
) }
>
<BlockManager />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ exports[`PreferencesModal should match snapshot when the modal is active small v
/>
</Section>
<Section
title="Manage visibility of blocks in the inserter"
description="Disable blocks that you don't want to appear in the inserter. They can always be toggled back on later."
title="Visible blocks"
>
<WithSelect(BlockManager) />
</Section>
Expand Down