Repository navigation
feat(hotkeys): Add trigger(), enabled getters, and call-site meta for app hotkeys #323
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
Open
KevinVandy
wants to merge
5
commits into
main
Choose a base branch
from
feat/hotkey-trigger
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,941
−998
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
eda5449
feat(hotkeys): Add trigger(), enabled getters, and call-site meta for…
KevinVandy 7d37519
ci: apply automated fixes
autofix-ci[bot] 345b94e
chore: Record Intent review of regenerated reference docs
KevinVandy e921fb8
fix(hotkeys): Keep keyup chord releases with getters, merge app hotke…
KevinVandy ecd6ce2
docs(hotkeys): Limit the keyup release note for enabled getters to ch…
KevinVandy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@tanstack/hotkeys': minor | ||
| --- | ||
|
|
||
| App hotkey registrations accept `meta`, which merges over the declared meta, and over `useHotkeys` common meta, for that registration only. A shared hotkey such as `list.focus-search` can register with `{ meta: { name: 'Search tables' } }` on one page. Registration lists, such as `useHotkeyRegistrations()`, show the merged meta; app hotkey lists and settings keep the declared one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@tanstack/hotkeys': minor | ||
| --- | ||
|
|
||
| `enabled` accepts a function, such as `enabled: () => dialog.open`. It is read on each key press, on `trigger()`, and when registration views report `status`. A `keydown` hotkey whose getter turns true during a key press doesn't fire on that press, the same as `setOptions({ enabled: true })`; a `keyup` chord still fires on that press's release. A getter that throws counts as `false` and is reported. The result changing doesn't notify registration subscribers, so lists show `status` as of their last update. In Vue, a getter is a reactive source, as for other Vue options. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@tanstack/hotkeys': minor | ||
| '@tanstack/hotkeys-devtools': patch | ||
| --- | ||
|
|
||
| Add `trigger()` to run a registration's callback without a key press, such as from a command palette. It is on registration views, such as those from `useHotkeyRegistrations()`, on the handle `register` returns, and on the manager as `trigger(id)`. The callback gets the same context as a key press and, unless you pass an event, a `keydown` for the hotkey (a `keyup` for a keyup hotkey) that is never dispatched. Only `enabled` is checked; scopes, focus, `ignoreInputs`, and `requireReset` don't apply, and `preventDefault` and `stopPropagation` aren't applied to the event. Triggering a sequence ends its attempt in progress. The devtools Trigger button now uses it, so it no longer runs disabled hotkeys. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.