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

Expose Patterns Modal to core/interface store like the Preferences modal #54199

Open
jhned opened this issue Sep 5, 2023 · 0 comments
Open
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Type] Enhancement A suggestion for improvement.

Comments

@jhned
Copy link
Contributor

jhned commented Sep 5, 2023

What problem does this address?

The only way to open the Patterns modal is to click on the Block Inserter, go to the Patterns tab, and then click "Explore All Patterns." This makes it more difficult for users to discover patterns. The Patterns modal visibility is controlled via useState in the BlockPatternsTabs component.

<Button
className="block-editor-inserter__patterns-explore-button"
onClick={ () =>
setShowPatternsExplorer( true )
}
variant="secondary"
>
{ __( 'Explore all patterns' ) }
</Button>

What is your proposed solution?

If the Patterns modal were accessible via the core/interface data store like the Preferences modal, then the Patterns modal could be opened via other methods.

export const PREFERENCES_MODAL_NAME = 'edit-site/preferences';
export default function EditSitePreferencesModal() {
const isModalActive = useSelect( ( select ) =>
select( interfaceStore ).isModalActive( PREFERENCES_MODAL_NAME )
);
const { closeModal, openModal } = useDispatch( interfaceStore );
const toggleModal = () =>
isModalActive ? closeModal() : openModal( PREFERENCES_MODAL_NAME );

We could then use wp.data.dispatch('core/interface').openModal(PATTERNS_MODAL_NAME) to open the modal.

@foosantos foosantos added [Type] Enhancement A suggestion for improvement. [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced labels Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Type] Enhancement A suggestion for improvement.
Projects
No open projects
Status: Todo
Development

No branches or pull requests

2 participants