Skip to content

Suggest mode: register the intent shortcuts only where they can be used - #81695

Merged
adamsilverstein merged 1 commit into
WordPress:suggest/inline-wiringfrom
adamsilverstein:fix/73411-f03-intent-shortcut-gate
Aug 23, 2026
Merged

adamsilverstein merged 1 commit into
WordPress:suggest/inline-wiringfrom
adamsilverstein:fix/73411-f03-intent-shortcut-gate

Conversation

@adamsilverstein

Copy link
Copy Markdown
Member

What

Fixes finding F-03 from the Suggest mode guided testing pass: https://github.com/adamsilverstein/gutenberg/blob/docs/suggest-mode-testing-2026-08-14/suggest-mode-testing/README.md

Part of #73411. Stacked on top of #80433 (suggest/inline-wiring), which is the base branch here.

The problem

The three intent shortcuts (core/editor/intent-edit, -suggest, -view) were registered whenever the Suggestion Mode experiment flag was on. Registration is what puts a shortcut in the Keyboard Shortcuts help modal, so the Site Editor listed "Switch to Edit mode.", "Switch to Suggest mode." and "Switch to View mode." under Global shortcuts.

None of them do anything there. wp_template has no editor.notes support, so no Mode menu renders and the handlers in global-keyboard-shortcuts/index.js return early. Pressing the combination gives no snackbar and no mode change.

The doc's diagnosis held up exactly on measurement: three gates for one feature, and the registration gate was the loose one. register-shortcuts.js checked isSuggestionModeEnabled() (the flag), while the Mode menu (PostTypeSupportCheck supportKeys="editor.notes") and the shortcut handlers (useCanSuggest()) both check the flag AND notes support.

The fix

Move the intent registrations into their own effect keyed on useCanSuggest(), the same runtime predicate the menu and the handlers use. editor.notes support arrives with the post type record, so the predicate starts false and flips once that resolves - hence a separate effect rather than a condition inside the existing one-shot registration. If it flips back the set is unregistered again, which is the pattern BlockEditorKeyboardShortcutsRegister already uses for its blockVisibility shortcuts.

One narrow file, packages/editor/src/components/global-keyboard-shortcuts/register-shortcuts.js, which no other open PR in this round touches.

Visible side effect worth calling out: in the post editor the three entries now sit at the end of the Global shortcuts list rather than in the middle of it, because they register on a later pass. Same shortcuts, same key combinations, same behavior.

Screenshots

Site Editor, Keyboard Shortcuts modal, Global shortcuts section. Before, the three intent shortcuts are advertised on a screen that cannot honor them:

Before: the Site Editor lists Switch to Edit mode, Switch to Suggest mode and Switch to View mode

After, they are gone and nothing else moved:

After: the Site Editor global shortcuts list no longer includes the three intent shortcuts

The post editor keeps all three. Before:

Before: the post editor lists the three intent shortcuts mid-list

After, still listed, now at the end of the section:

After: the post editor still lists the three intent shortcuts, at the end of the global section

Testing instructions

Enable the Suggestion Mode experiment (Gutenberg > Experiments) and use a block theme.

Before (on suggest/inline-wiring):

  1. Open the Site Editor and edit any template.
  2. Press Shift+Alt+Cmd+H (Mac) or Shift+Alt+H to open Keyboard shortcuts.
  3. Under Global shortcuts, note "Switch to Edit mode.", "Switch to Suggest mode." and "Switch to View mode.".
  4. Close the modal and press Shift+Alt+Cmd+X. Nothing happens: no snackbar, no mode change, and there is no Mode section in the Options menu.

After (this branch):

  1. Repeat steps 1-3. The three entries are no longer listed.
  2. Open a new post, open Keyboard shortcuts, and confirm the three entries are still listed there.
  3. Close the modal and press Shift+Alt+Cmd+X. The "You're suggesting" snackbar appears and the Options menu shows Suggesting selected.

Automated coverage

Unit, packages/editor/src/components/global-keyboard-shortcuts/test/register-shortcuts.js:

  • "registers the intent shortcuts when the post type can host suggestions"
  • "leaves the intent shortcuts unregistered when the post type has no notes support"
  • "leaves the intent shortcuts unregistered when the experiment is off"
  • "removes the intent shortcuts when notes support goes away"

Verified red on the unmodified base first: the second and fourth fail there with all three names still registered, while the first and third (the controls) pass on base and after. All four pass with the fix.

E2E, test/e2e/specs/site-editor/suggestion-mode-intent-shortcuts.spec.js:

  • "are listed in the post editor, where the Mode menu is offered"
  • "still switch the intent in the post editor"
  • "are not listed in the Site Editor, where no post type supports notes"

Same story: on a base build the two post editor controls pass and the Site Editor one fails on "Switch to Suggest mode." still being visible; with the fix all three pass, run with --repeat-each=5 for 15/15. The neighbouring suites were run against the fixed build too - shortcut-help.spec.js and suggestion-mode.spec.js give 23 passed with the one known pre-existing failure, "a closed sidebar stays closed when a suggestion is created", which is F-03's neighbour F-17 and is fixed separately in #81671.

AI Use

Claude Code did the typing here, I did the asking. Description too. I will review and test.

The Keyboard Shortcuts help modal lists whatever is registered, so
registering the Edit/Suggest/View intent shortcuts behind the experiment
flag alone advertised "Switch to Suggest mode." in the Site Editor, where
`wp_template` has no `editor.notes` support, no Mode menu renders and the
key combination does nothing.

Register them on the same runtime predicate the Mode menu and the
shortcut handlers already use, and remove them again if it stops passing,
so all three gates agree.
@github-actions

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions Bot added the [Package] Editor /packages/editor label Aug 15, 2026
adamsilverstein added a commit to adamsilverstein/gutenberg that referenced this pull request Aug 15, 2026
@adamsilverstein adamsilverstein added the [Type] Bug An existing feature does not function as intended label Aug 15, 2026
@adamsilverstein
adamsilverstein merged commit 1f317ed into WordPress:suggest/inline-wiring Aug 23, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Editor /packages/editor [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant