Use search_columns=post_title for parent page selector REST API searches#78683
Use search_columns=post_title for parent page selector REST API searches#78683sarthaknagoshe2002 wants to merge 2 commits into
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @hamsterkacke. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. |
Mamaduka
left a comment
There was a problem hiding this comment.
Thanks for the PR, @sarthaknagoshe2002!
This works as expected ✅
P.S. GitHub actions are experiencing some issues, and we might have to wait a bit until that's resolved
What?
Closes #74631
This PR ensures that the parent page selector restricts its server-side REST API queries to search specifically against
post_titleinstead of executing a global keyword search across titles, excerpts, and content.Why?
When searching for a parent page in either the Page Attributes sidebar or the DataViews interface, the client-side filters records strictly by title. However, the REST API returns any page containing the search term in its body or excerpt.
If too many pages match via content, they consume the
per_page: 100payload budget and push actual title matches out of the response. Furthermore, non-title matches that are returned get silently hidden by the client-side UI, resulting in zero visible options or unexpected missing results for the user.How?
Added
search_columns: [ 'post_title' ]to thequeryobject configuration when a search filter (fieldValue) is active across both implementations of the selector:packages/editor/src/components/page-attributes/parent.js(Classic Block Editor sidebar)packages/fields/src/fields/parent/parent-edit.tsx(DataViews / Site Editor interface)Testing Instructions