-
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
Query loop format controls: Fix JavaScript error #65551
Conversation
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. |
Size Change: +70 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
@@ -68,7 +68,7 @@ export default function FormatControls( { onChange, query: { format } } ) { | |||
.filter( Boolean ); | |||
|
|||
const suggestions = formats | |||
.filter( ( item ) => ! format.includes( item.value ) ) | |||
.filter( ( item ) => ! normalizedFormats.includes( item.value ) ) |
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.
Just to refresh my memory, this filter removes values from the suggestions already assigned to the Query, correct?
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.
Yes.
Shall I add a comment about it? I still need to create a new PR to apply the changes requested in the review of the sync with core, I could add it then.
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.
There's no need for a comment. I was just double checking for myself 😄
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.
Thank you, @carolinan!
The fix tests well for me ✅
Fixes a JavaScript error in FormatControls by ensuring that the correct constant is used when populating the suggestions in the FormTokenField. Co-authored-by: carolinan <poena@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: annezazu <annezazu@git.wordpress.org>
I just cherry-picked this PR to the wp/6.7 branch to get it included in the next release: 4081b90 |
There was a conflict while trying to cherry-pick the commit to the wp/6.7 branch. Please resolve the conflict manually and create a PR to the wp/6.7 branch. PRs to wp/6.7 are similar to PRs to trunk, but you should base your PR on the wp/6.7 branch instead of trunk.
|
Fixes a JavaScript error in FormatControls by ensuring that the correct constant is used when populating the suggestions in the FormTokenField. Co-authored-by: carolinan <poena@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: annezazu <annezazu@git.wordpress.org>
I just cherry-picked this PR to the release/19.3 branch to get it included in the next release: 35f0201 |
What?
Fixes #65550.
This PR fixes a JavaScript error that happens in the
FormatControls
in the query loop block when theformat
parameter in thequery
block attribute is not anarray
.This error can occur for example when an existing query loop pattern is placed in a post or page, for example
when a block pattern with a query loop is added. Presumably because the 'format' is missing in these existing patterns.
Why? & How
FormatControls
already creates a constant callednormalizedFormats
with the purpose of ensuring thatformat
is anarray
. - But it was not used in all instances where it was needed:This PR updates
FormatControls
to usenormalizedFormats
for creating the list of suggested formats in theFormTokenField
.Testing Instructions
First please enable post format support in the active theme, for example in functions.php.
Example:
Add some test posts, both with and without post formats assigned.
-If you are using Twenty Twenty-Four, test a page pattern:
Create a new page: You will be prompted with a modal when you create a new page.
In this modal, select the pattern "Portfolio Home with post featured images".
In this portfolio design there are multiple query loop blocks.
Open the ListView to locate the query loops easier.
Select a query loop and then open the Filters panel in the block settings sidebar.
In the Filters panel, click on "Formats".
Confirm that there are no block validation errors or other issues:
A new input field should show in the Filters panel.
Select the input field, and type or select a post format name.
Confirm that the query loop displays the selected format.
Test an inserted pattern (any theme)
Create a new post or page.
Open the block inserter in top left corner, and select the Patterns tab.
Select the "Posts" pattern category, and insert any pattern from this list.
Select a query loop and then open the Filters panel in the block settings sidebar.
In the Filters panel, click on "Formats".
Confirm that there are no block validation errors or other issues:
A new input field should show in the Filters panel.
Select the input field, and type or select a post format name.
Confirm that the query loop displays the selected format.