-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Shuffle template parts #47763
Shuffle template parts #47763
Conversation
Size Change: +194 B (0%) Total Size: 1.31 MB
ℹ️ View Unchanged
|
If one has an understanding of what template parts are and how they work I think this probably would be expected. Whether users are able to make that interpretation is a separate issue that (imo) shouldn't get in the way of the best approach here. It seems sensible to present the user with options to either shuffle the selected template part, or replace it with another one entirely. (On that note there may be an argument to promote the Replace button back to the toolbar so that these options are grouped together with Edit, but obviously that's not something to do here). It's a real shame that the shuffle button jumps around between shuffles, it really disrupts the experience quite a bit. It's most egregious with headers where the toolbar most likely appears below the block. I don't suppose there's much we can do about this though 🤔 Something about the spacing of the Shuffle / Edit buttons feels a bit off. Increasing the padding between the buttons and the separators would help a bit. |
Yeah, I guess solving it would probably mean changing how block toolbar works, which is out of the scope of this PR 😞 .
What do you think if we move it to another group? |
Ah, no I don't think they need to be separate groups. I was thinking more along the lines of increasing the horizontal padding on the group itself. Maybe we leave that as it is for now and revisit when (if) we move the Replace button into this group as well. One additional thought in terms of the UX, I think it might be useful to add a tooltip to further explain the shuffle behavior, maybe something like:
What do you think? |
Flaky tests detected in 107abe4. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4142033601
|
What?
In addition to #47594. An alternative approach of taking #44581 to shuffle template parts.
Why?
See #44581
How?
Add a "Shuffle" button to the template part blocks. We already have the "Replace template part" workflow, this is a different way to do a similar thing via a toolbar button.
Currently, this PR replaces the inner blocks of the template part block when shuffling through patterns, which sometimes isn't ideal as the users probably don't expect their content across different pages to change. This, however, is how template part currently works, and we still have a "note" when users save the entities.
An alternative approach shown in 3d24633 follows the same logic as in the "Replace template part" workflow. Instead of replacing the existing template part block's inner blocks, it completely switches the template part to another. The tricky part of this is when handling patterns. We have to create a new template part when first shuffling to a new pattern (there is currently a bug that the focus will be lost during this transition), resulting in the unexpected creation of multiple template parts when the users are just hitting the "Shuffle" button. A pattern will only be created once when converting to a template part though, so that it won't keep creating dummy template parts infinitely.
Another idea shared by @talldan is to have the template part blocks reference patterns in some way. Still not sure how that would work at this stage though.
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
Kapture.2023-02-05.at.00.26.56.mp4