-
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
Allow adding posts and pages with custom titles from the command menu #49893
Conversation
@@ -44,7 +44,7 @@ const getWPAdminAddCommandLoader = ( postType ) => | |||
const commands = useMemo( | |||
() => [ | |||
{ | |||
name: 'core/wp-admin/add-' + postType, | |||
name: 'core/wp-admin/add-' + postType + '-' + search, |
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.
The command menu package we use, rely on the "value" prop (which is the name of the command for us) to actually filter the results. This command was returned by this hook but was hidden by the search algorithm.
Size Change: +5 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
Flaky tests detected in b64631c. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4732216088
|
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.
Since this was mostly a regression, let's land this. Works for me:
We should probably come back to this, as we've discussed a "new page" modal that allows you to draft pages quickly, that we can unify on (#49873 (comment)) — and it would be nice if this commandbar hooked into that as well. Both in terms of connecting with it (type "Contact", press Add new page, and it seamlessly transitioned into the new page modal with the title field pre-filled), but also design/position wise, so it can kind of "feel" like a single modal.
@youknowriad I'm not sure how to open the command menu. Using ctrl+k sets the focus in the browser address bar. Other keyboard combinations do nothing. My environment: linux (ubuntu) + chrome or firefox browser. |
@oandregal Since we're using the keyboard shortcuts package, the focus needs to be within the page when you hit the ctrl + k. Can you try that? |
@youknowriad Apparently, CTRL+K is a browser shortcut (chrome, firefox) in Windows and Linux. Gravacao.de.ecra.a.partir.de.19-04-2023.10.05.46.webmI've also noticed that CTRL+K is also used for opening the link panel, when the focus is on the editor canvas: Gravacao.de.ecra.a.partir.de.19-04-2023.10.12.29.webm |
@oandregal yeah, we're aware of this but at least in Mac OS Firefox, I managed to prevent the default browser behavior. For the link panel, one of the ideas was to actually use a contextual command menu to insert the link there. (unify both) Do you think you can take a look to see if you can find a way to prevent the default browser behavior in Linux? also cmd+k is a common pattern for this kind of menus across the web. In fact the lib is called cmdk https://github.com/pacocoursey/cmdk That said, this discussion is independent from the current PR, so I'm going to merge this one and I think we should continue exploring a solution to prevent the default browser behavior. |
Related to #48457
What?
This regressed somewhere in the middle of the initial command menu PR but basically the idea is that you can type anything in the command bar and the results proposes results to create pages or posts with what you typed. It was an idea tossed by @jasmussen
Testing Instructions
1- Open the site editor
2- Hit cmd+k
3- Type a random post title
4- you click
add post title "your title"
to navigate to the post editor with that custom title prefilled.