-
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
Pattern Shuffling: Make the results deterministic #60074
Conversation
Size Change: +252 B (0%) Total Size: 1.72 MB
ℹ️ View Unchanged
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
No! I'll fix it :) |
Good stuff. Regarding metadata.name, is it possible to name it only if a name does not exist? For example, TT4 has a testimonials pattern with a name assigned to the group block. I think it may be unexpected that the name would be omitted. What do you think? |
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.
Looks good to me. Looking forward to #60088 in as well, which will improve the shuffle results more.
176bbd8
to
27fe1bf
Compare
It would be good to have a technical review on this cc @jorgefilipecosta @draganescu |
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.
I think this is good but we should consider if we should then cycle instead of shuffle as UX
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.
It works well for me, this is a nice simple solution.
I think this is good but we should consider if we should then cycle instead of shuffle as UX
@draganescu I guess it depends on whether the user can tell the difference.
categories: pattern.categories, | ||
patternName: pattern.name, |
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.
Nit, but I wonder if these could be grouped together:
shuffle: {
categories: pattern.categories,
name: pattern.name,
}
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.
That does mean we can be consistent with naming which is nicer, but they may be used for things other than shuffle...
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.
True. The patternName
could be useful for a few things.
The categories
are only for the originally inserted pattern though, as a user shuffles, the newly shown pattern might have different categories to those stored in the attribute (though will always have one category in common), so that feels more like a search parameter for the shuffle feature.
* Pattern Shuffling: Make the results deterministic * Use the title field as a name and save the pattern name in patternName * Only use the pattern name if the group doesn't have a name * updated snapshots for inserting-blocks.spec.js * fixed test --------- Co-authored-by: MaggieCabrera <maggie.cabrera@automattic.com>
* Pattern Shuffling: Make the results deterministic * Use the title field as a name and save the pattern name in patternName * Only use the pattern name if the group doesn't have a name * updated snapshots for inserting-blocks.spec.js * fixed test --------- Co-authored-by: MaggieCabrera <maggie.cabrera@automattic.com>
What?
This changes the way pattern shuffling works so that the results are deterministic not random. The patterns just cycle through the list of patterns in the category.
Why?
Random shuffle isn't very useful - you might see the same pattern multiple times while not seeing the other options. It's more useful for users to be presented with the options in a more evenly spread way.
How?
We find the index of the current pattern in the category and return the next one in that array, or the first one if its the last one.
Testing Instructions
Screenshots or screencast
Screen.Recording.2024-03-21.at.13.24.15.mov