mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 09:38:29 +02:00
Cmd+n to open dropdown
This commit is contained in:
@@ -31,7 +31,7 @@ export function RecentRequestsDropdown({ className }: Pick<ButtonProps, 'classNa
|
|||||||
useKey('k', (e) => {
|
useKey('k', (e) => {
|
||||||
if (e.metaKey) {
|
if (e.metaKey) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
dropdownRef.current?.toggle(0);
|
dropdownRef.current?.toggle();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -42,12 +42,12 @@ export function RecentRequestsDropdown({ className }: Pick<ButtonProps, 'classNa
|
|||||||
});
|
});
|
||||||
|
|
||||||
useHotKey('requestSwitcher.prev', () => {
|
useHotKey('requestSwitcher.prev', () => {
|
||||||
if (!dropdownRef.current?.isOpen) dropdownRef.current?.open(1);
|
if (!dropdownRef.current?.isOpen) dropdownRef.current?.open();
|
||||||
dropdownRef.current?.next?.();
|
dropdownRef.current?.next?.();
|
||||||
});
|
});
|
||||||
|
|
||||||
useHotKey('requestSwitcher.next', () => {
|
useHotKey('requestSwitcher.next', () => {
|
||||||
if (!dropdownRef.current?.isOpen) dropdownRef.current?.open(-1);
|
if (!dropdownRef.current?.isOpen) dropdownRef.current?.open();
|
||||||
dropdownRef.current?.prev?.();
|
dropdownRef.current?.prev?.();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ export const ResponsePane = memo(function ResponsePane({ style, className, activ
|
|||||||
</HStack>
|
</HStack>
|
||||||
|
|
||||||
{activeResponse?.error ? (
|
{activeResponse?.error ? (
|
||||||
<Banner color="danger" className="m-2 mt-4">
|
<Banner color="danger" className="m-2">
|
||||||
{activeResponse.error}
|
{activeResponse.error}
|
||||||
</Banner>
|
</Banner>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ export const SidebarActions = memo(function SidebarActions() {
|
|||||||
icon={hidden ? 'leftPanelHidden' : 'leftPanelVisible'}
|
icon={hidden ? 'leftPanelHidden' : 'leftPanelVisible'}
|
||||||
/>
|
/>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
|
openOnHotKeyAction="http_request.create"
|
||||||
items={[
|
items={[
|
||||||
{
|
{
|
||||||
key: 'create-http-request',
|
key: 'create-http-request',
|
||||||
label: 'HTTP Request',
|
label: 'HTTP Request',
|
||||||
hotKeyAction: 'http_request.create',
|
|
||||||
onSelect: () => createHttpRequest.mutate({}),
|
onSelect: () => createHttpRequest.mutate({}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { debounce } from '../lib/debounce';
|
|||||||
import { useOsInfo } from './useOsInfo';
|
import { useOsInfo } from './useOsInfo';
|
||||||
|
|
||||||
export type HotkeyAction =
|
export type HotkeyAction =
|
||||||
|
| 'dropdown.close'
|
||||||
| 'environmentEditor.toggle'
|
| 'environmentEditor.toggle'
|
||||||
| 'hotkeys.showHelp'
|
| 'hotkeys.showHelp'
|
||||||
| 'grpc_request.send'
|
| 'grpc_request.send'
|
||||||
@@ -19,6 +20,7 @@ export type HotkeyAction =
|
|||||||
| 'urlBar.focus';
|
| 'urlBar.focus';
|
||||||
|
|
||||||
const hotkeys: Record<HotkeyAction, string[]> = {
|
const hotkeys: Record<HotkeyAction, string[]> = {
|
||||||
|
'dropdown.close': ['Escape'],
|
||||||
'environmentEditor.toggle': ['CmdCtrl+Shift+e'],
|
'environmentEditor.toggle': ['CmdCtrl+Shift+e'],
|
||||||
'grpc_request.send': ['CmdCtrl+Enter', 'CmdCtrl+r'],
|
'grpc_request.send': ['CmdCtrl+Enter', 'CmdCtrl+r'],
|
||||||
'hotkeys.showHelp': ['CmdCtrl+Shift+/'],
|
'hotkeys.showHelp': ['CmdCtrl+Shift+/'],
|
||||||
@@ -34,6 +36,7 @@ const hotkeys: Record<HotkeyAction, string[]> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const hotkeyLabels: Record<HotkeyAction, string> = {
|
const hotkeyLabels: Record<HotkeyAction, string> = {
|
||||||
|
'dropdown.close': 'Close Dropdown',
|
||||||
'environmentEditor.toggle': 'Edit Environments',
|
'environmentEditor.toggle': 'Edit Environments',
|
||||||
'grpc_request.send': 'Send Message',
|
'grpc_request.send': 'Send Message',
|
||||||
'hotkeys.showHelp': 'Show Keyboard Shortcuts',
|
'hotkeys.showHelp': 'Show Keyboard Shortcuts',
|
||||||
@@ -81,7 +84,7 @@ export function useAnyHotkey(
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Sometimes the keyup event doesn't fire, so we clear the keys after a timeout
|
// Sometimes the keyup event doesn't fire, so we clear the keys after a timeout
|
||||||
const clearCurrentKeys = debounce(() => currentKeys.current.clear(), 1000);
|
const clearCurrentKeys = debounce(() => currentKeys.current.clear(), 5000);
|
||||||
|
|
||||||
const down = (e: KeyboardEvent) => {
|
const down = (e: KeyboardEvent) => {
|
||||||
if (options.enable === false) {
|
if (options.enable === false) {
|
||||||
|
|||||||
Reference in New Issue
Block a user