-
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
Fix: Changing sorting direction on patterns does nothing. #64508
Fix: Changing sorting direction on patterns does nothing. #64508
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. |
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.
Thanks for the quick fix!
This PR works as expected, but I have two questions:
- Why doesn't this issue occur in Templates or Pages? Sort by never seems to be
undefined
there 🤔 Are the initial values of the Sort By explicitly set for these? - Is it possible that the first field where
enableSorting
is notfalse
doesn't match the field when shown in the Sort By?
Hi @t-hamano, excellent questions.
In both of these cases, there is a default sorting passed on the view, on Templates ascending by title on pages descending by date. So the bug is not noticeable.
No that will not happen because the select HTML element shows the first option element as the selected option.
In our code, we filter the fields for sortable and pass each field as an option, in the order they appear, so the first option will appear as selected. |
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 for the detailed explanation! If so, I think this PR makes sense 👍
The sorting direction controls are not working for patterns, that happens because we don't include a default sorting field when changing the direction, this PR fixes the issue.
Now when changing the sorting direction, if no sorting field is set changing the sorting direction assigns the first sortable field as the sort-by field.
This bug was reported at #64380 (review) by @t-hamano.
Testing Instructions
Go to the patterns sections, open the view configuration UI and verify the sort controls work as expected.