-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Migrating BlockPatternSetup
to use updated Composite
implementation
#55425
Conversation
- Removes `__unstableComposite` imports from `@wordpress/components` - Adds private `Composite*` exports from `@wordpress/components` - Refactors `BlockPatternSetup` and subcomponents to use updated `Composite` components - Additionally rewords UX to improve keyboard/AT experience
packages/block-editor/src/components/block-pattern-setup/setup-toolbar.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/block-pattern-setup/setup-toolbar.js
Outdated
Show resolved
Hide resolved
setActiveSlide( ( active ) => | ||
Math.max( active - 1, 0 ) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that previous/next buttons are no longer disabled (see CarouselNavigation
), this is necessary to keep the active slide within bounds.
setActiveSlide( ( active ) => | ||
Math.min( active + 1, patterns.length - 1 ) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that previous/next buttons are no longer disabled (see CarouselNavigation
), this is necessary to keep the active slide within bounds.
@@ -85,7 +85,7 @@ | |||
align-items: center; | |||
justify-content: space-between; | |||
border-top: 1px solid $gray-300; | |||
align-self: flex-end; | |||
align-self: stretch; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems to make the toolbar more stable, preventing it from jumping around as slide height varies.
Size Change: +133 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 This looks good to me, but I'd like to leave the official approval to someone more familiar with block-editor
and Composite
Thanks for the PR @andrewhayward! I think it becomes really obvious here, where we also make more changes besides the |
I've reverted a lot of the original changes, to reduce the scope of the PR somewhat. So it's now much more focused on swapping out the old There are still a few additional updates, but nothing functional beyond allowing the carousel navigation buttons to retain focus when disabled. It is otherwise just minor semantic alterations. |
It's a good point @ntsekouras, and one I've been thinking about quite a lot recently. Would be great to see more documentation in general for contributors to Gutenberg, around where and how different parts of the codebase are used, etc. |
Absolutely. Let's focus on finishing the migration to the new ariakit components first, and then provide some good storybook docs and examples for this new version |
What?
This PR updates
BlockPatternSetup
in@wordpress/block-editor
(and related sub-components) to use the updatedComposite
implementation from #54225.Additionally, it reworks some of the UX to improve the keyboard/AT experience.
Why?
In #54225, an updated implementation of
Composite
was added to@wordpress/components
. As per #55224, all consumers ofComposite
need to migrate from the old version to the new version.How?
__unstableComposite
imports from@wordpress/components
Composite*
exports from@wordpress/components
BlockPatternSetup
and subcomponents to use updatedComposite
componentsTesting Instructions
Unfortunately
BlockPatternSetup
is no longer used in Gutenberg (see #52374), but because it is used by various plugins (despite being marked as 'experimental'!), we need to keep it around.With the JetPack plugin installed, add a JetPack forms block to a page/post, and open the "Form Patterns" dialog.
The (default) grid view should present as a single tab stop, with arrow keys moving up and down through the various options, as before. (This somewhat confusingly doesn't behave as a grid, but that's a problem outside of the scope of this PR!)
The carousel view should also behave as before, with the arrow buttons at the bottom navigating through the different patterns.