-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat: Add keyboard shortcut to perform an action on the currently focused element #9673
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
base: v13
Are you sure you want to change the base?
Changes from all commits
0ef22ea
8114110
8dbb0fa
3c389f1
3c83dd7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -279,6 +279,14 @@ export class TextInputBubble extends Bubble { | |
| getEditor() { | ||
| return this.editor; | ||
| } | ||
|
|
||
| /** | ||
| * Handles the user acting on this bubble via keyboard navigation by focusing | ||
| * the comment editor. | ||
| */ | ||
| performAction() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason we're adding this to these
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, see the other reply on the workspace bubble. |
||
| getFocusManager().focusNode(this.getEditor()); | ||
| } | ||
| } | ||
|
|
||
| Css.register(` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,11 +6,15 @@ | |
|
|
||
| import {Msg} from './msg.js'; | ||
| import {Toast} from './toast.js'; | ||
| import {getShortActionShortcut} from './utils/shortcut_formatting.js'; | ||
| import * as userAgent from './utils/useragent.js'; | ||
| import type {WorkspaceSvg} from './workspace_svg.js'; | ||
|
|
||
| const unconstrainedMoveHintId = 'unconstrainedMoveHint'; | ||
| const constrainedMoveHintId = 'constrainedMoveHint'; | ||
| const helpHintId = 'helpHint'; | ||
| const blockNavigationHintId = 'blockNavigationHint'; | ||
| const workspaceNavigationHintId = 'workspaceNavigationHint'; | ||
|
|
||
| /** | ||
| * Nudge the user to use unconstrained movement. | ||
|
|
@@ -62,3 +66,37 @@ export function clearMoveHints(workspace: WorkspaceSvg) { | |
| Toast.hide(workspace, constrainedMoveHintId); | ||
| Toast.hide(workspace, unconstrainedMoveHintId); | ||
| } | ||
|
|
||
| /** | ||
| * Nudge the user to open the help. | ||
| * | ||
| * @param workspace The workspace. | ||
| */ | ||
| export function showHelpHint(workspace: WorkspaceSvg) { | ||
| const shortcut = getShortActionShortcut('list_shortcuts'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we handle the potential case where
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is a possibility, I'm not sure how we might helpfully handle it though. End users wouldn't be able to do anything about it, I suppose we could just not show the toast? Or did you have something else in mind? |
||
| const message = Msg['HELP_PROMPT'].replace('%1', shortcut); | ||
| const id = helpHintId; | ||
| Toast.show(workspace, {message, id}); | ||
| } | ||
|
|
||
| /** | ||
| * Tell the user how to navigate inside blocks. | ||
| * | ||
| * @param workspace The workspace. | ||
| */ | ||
| export function showBlockNavigationHint(workspace: WorkspaceSvg) { | ||
| const message = Msg['KEYBOARD_NAV_BLOCK_NAVIGATION_HINT']; | ||
| const id = blockNavigationHintId; | ||
| Toast.show(workspace, {message, id}); | ||
| } | ||
|
|
||
| /** | ||
| * Tell the user how to navigate inside the workspace. | ||
| * | ||
| * @param workspace The workspace. | ||
| */ | ||
| export function showWorkspaceNavigationHint(workspace: WorkspaceSvg) { | ||
| const message = Msg['KEYBOARD_NAV_WORKSPACE_NAVIGATION_HINT']; | ||
| const id = workspaceNavigationHintId; | ||
| Toast.show(workspace, {message, id}); | ||
| } | ||
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.
Is there a particular reason to add this to two
Bubblesubclasses as opposed to just the base class?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.
Yes, they're doing different things; the mini workspace bubble focuses its workspace and the text input bubble focuses its comment editor. Bubble is an abstract class and there's no common behavior, so each subclass does its own thing.