CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat: added keyword support & added basic keywords for post/page #70624
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
feat: added keyword support & added basic keywords for post/page #70624
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 getting this PR up!
I think it's a good change. Are there any blockers or prerequisites to getting it in?
<Command.Item | ||
key={ command.name } | ||
value={ command.searchLabel ?? command.label } | ||
keywords={ command.keywords } |
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.
Oh I see this is built-in behaviour in https://www.npmjs.com/package/cmdk
Nice!
callback: addNewPage, | ||
keywords: [ | ||
__( 'page' ), | ||
__( 'new' ), |
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 expect there are languages in which "new" might not feature in the translation for "Add new page"
so it seems safe to duplicate, at least in English.
None. The CMDK package is already used and we are just extending the implementation using it. |
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 this PR, and for the tests 🙇🏻
I think this needs some more work. I expect (and e2e tests did as well) that keyword combos would work during the search, but they return no results. Try "create page" or "new page". Discovered while debugging related test failures - #71293. |
Oh thanks for catching that @Mamaduka I got lured in by locally passing tests before the merge 🙃 I wonder if it should be used in conjunction with the filter function? @Mayank-Tripathi32 what do you think? See https://github.com/pacocoursey/cmdk#command-cmdk-root
<Command
filter={(value, search, keywords) => {
const extendValue = value + ' ' + keywords.join(' ')
if (extendValue.includes(search)) return 1
return 0
}}
/> |
Happens all the time when branches get out of sync 😅 |
What?
Closes #70595
Adds "create" as a keyword for post/page commands in Command Palette to improve user experience and searchability.
Why?
Currently, when users open the Command Palette (⌘ + K) and type "create post" or "create page", no matching commands are shown. However, typing "add post" or "add page" works as expected. Many end users naturally think of "creating" content rather than "adding" it, so it would be more intuitive if "create" were recognized as an alias or keyword for the existing "Add Post" and "Add Page" commands.
This PR addresses the issue described in #70595 by adding comprehensive keywords support to both static and dynamic commands in the Command Palette.
How?
Core Implementation
useCommand
hook - Addedkeywords: command.keywords
toregisterCommand
call for static commandscommands
reducer - Addedkeywords: action.keywords
to store keywords in state@property {string[]=} keywords
toWPCommandConfig
typedefcmdk
library's built-in keywords support - Used properkeywords
prop onCommand.Item
componentsCommand Updates
['post', 'new', 'post new', 'add new post', 'create post', 'create new post', 'create']
['page', 'new', 'page new', 'add new page', 'create page', 'create new page', 'create']
Documentation
Testing Instructions
⌘ + K
(orCtrl + K
on Windows/Linux) to open the Command PaletteTesting Instructions for Keyboard
⌘ + K
to open Command PaletteScreenshots or screencast
Note: The implementation ensures backward compatibility - all existing search terms continue to work while adding the new "create" keyword functionality.