Repository navigation
feat(devtools): Handle keyboard shortcuts with TanStack Hotkeys #582
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
4
commits into
main
Choose a base branch
from
feat/use-tanstack-hotkeys
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,081
−645
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bb7338a
feat(devtools): Handle keyboard shortcuts with TanStack Hotkeys
KevinVandy cd7a133
test(e2e): Press the open hotkey with the keyboard
KevinVandy 6ff3719
feat(devtools): Record the open shortcut in the picture-in-picture wi…
KevinVandy f4d5dee
feat(devtools): Convert shortcuts in the old format instead of droppi…
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,14 @@ | ||
| --- | ||
| '@tanstack/devtools': minor | ||
| --- | ||
|
|
||
| Handle every devtools keyboard shortcut with TanStack Hotkeys. | ||
|
|
||
| - `openHotkey` is a hotkey string in TanStack Hotkeys syntax, such as `'Control+~'` (the default) or `'Mod+Shift+D'`. The array form, such as `['Control', '~']`, is deprecated. It still works and converts to a string when the devtools load. | ||
| - `inspectHotkey` takes modifier names. `CtrlOrMeta` is deprecated in favor of `Mod`, which is Command on macOS and Control on other platforms. The default is `['Shift', 'Alt', 'Mod']`. | ||
| - Shortcuts saved in the Settings tab by an older version convert the same way, so they keep working. A saved shortcut that has no TanStack Hotkeys form, such as two keys pressed together, falls back to the config or the default. Before, `CtrlOrMeta` matched either key on every platform. `Mod` matches Command on macOS and Control elsewhere. | ||
| - The Settings tab records the open shortcut from a key press, including in the picture-in-picture window, and rejects a shortcut that the app already registered with TanStack Hotkeys. | ||
| - Escape no longer closes the devtools when it closes an open dialog or popover of the app. Escape while moving a pane with the keyboard cancels the move and leaves the panel open. | ||
| - Alt+M for magnetic trigger mode now works on macOS, and it no longer fires while you type in a text field. | ||
| - The devtools hotkeys are in the `tanstack-devtools` scope. In an app that also uses TanStack Hotkeys, an enabled devtools hotkey runs instead of the app's global hotkey for the same key, such as Escape while the panel is open. An app with an exclusive scope can keep the devtools hotkeys working with `exclusive: { allow: ['tanstack-devtools'] }`. | ||
| - `@tanstack/hotkeys` is a new dependency, and `@solid-primitives/keyboard` is removed. An app that already uses TanStack Hotkeys shares one hotkey manager with the devtools. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import { expect, test } from '@playwright/test' | ||
| import { DevtoolsPage, SELECTORS } from '@tanstack/devtools-e2e' | ||
| import type { Page } from '@playwright/test' | ||
|
|
||
| /** | ||
| * The PiP button opens a real popup with `window.open`, and Solid moves the | ||
| * open panel into it. These check that the devtools keys work there. | ||
| */ | ||
| const openInPip = async (page: Page) => { | ||
| const dt = new DevtoolsPage(page) | ||
| await dt.goto() | ||
| await dt.openViaTrigger() | ||
| const popupOpened = page.waitForEvent('popup') | ||
| await page.getByTestId(SELECTORS.pipButton).click() | ||
| const popup = await popupOpened | ||
| const pip = new DevtoolsPage(popup) | ||
| await expect(pip.panel()).toBeVisible() | ||
| return { popup, pip } | ||
| } | ||
|
|
||
| const storedOpenHotkey = (page: Page) => | ||
| page.evaluate( | ||
| () => | ||
| JSON.parse(localStorage.getItem('tanstack_devtools_settings') ?? '{}') | ||
| .openHotkey, | ||
| ) | ||
|
|
||
| test('records the open shortcut inside the picture-in-picture window', async ({ | ||
| page, | ||
| }) => { | ||
| const { popup, pip } = await openInPip(page) | ||
| await pip.tab('settings').click() | ||
| await popup.getByRole('button', { name: 'Record shortcut' }).click() | ||
| await popup.keyboard.press('Alt+Shift+KeyY') | ||
|
|
||
| await expect.poll(() => storedOpenHotkey(page)).toBe('Alt+Shift+Y') | ||
| await expect( | ||
| popup.getByRole('button', { name: 'Record shortcut' }), | ||
| ).toBeVisible() | ||
| }) | ||
|
|
||
| test('Escape cancels recording inside the picture-in-picture window', async ({ | ||
| page, | ||
| }) => { | ||
| const { popup, pip } = await openInPip(page) | ||
| await pip.tab('settings').click() | ||
| await popup.getByRole('button', { name: 'Record shortcut' }).click() | ||
| await expect( | ||
| popup.getByRole('button', { name: /Press a shortcut/ }), | ||
| ).toBeVisible() | ||
| await popup.keyboard.press('Escape') | ||
|
|
||
| await expect( | ||
| popup.getByRole('button', { name: 'Record shortcut' }), | ||
| ).toBeVisible() | ||
| // Escape only cancelled the recording. | ||
| await expect(pip.panel()).toBeVisible() | ||
| expect(await storedOpenHotkey(page)).toBe('Control+~') | ||
| }) | ||
|
|
||
| test('a pane moves with the keyboard inside the picture-in-picture window', async ({ | ||
| page, | ||
| }) => { | ||
| const { popup, pip } = await openInPip(page) | ||
| await pip.stripEntry('Event Probe').click() | ||
| await expect(pip.groupTabBars()).toHaveCount(2) | ||
|
|
||
| await pip.pluginTab('event-probe').focus() | ||
| await popup.keyboard.press('Enter') | ||
| await expect(pip.status()).toContainText('picked up') | ||
| await popup.keyboard.press('ArrowLeft') | ||
| await popup.keyboard.press('Enter') | ||
| await expect(pip.groupTabBars()).toHaveCount(1) | ||
| }) |
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.
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.
Align the declared Node range with the runtime dependency.
@tanstack/devtoolsdeclares"engines": { "node": ">=18" }. Its runtime dependency@tanstack/hotkeys(^0.39.0) requires Node>=20. The hotkeys package has declared this floor across its published releases.With default npm or pnpm settings, Node 18 consumers receive an engines warning during install. With
engine-strictenabled, the same install fails. The published range therefore promises support that the dependency does not provide.Make the declared range match the dependency. Either raise the package's
engines.nodeto a Node 20 minimum and document the change, or choose a dependency version that supports Node 18.