move keyboard shortcuts to global listener in url-bar (#5030)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>
Co-authored-by: Mark Kim <103070941+marckong@users.noreply.github.com>

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>
Co-authored-by: Mark Kim <103070941+marckong@users.noreply.github.com>
This commit is contained in:
James Gatz
2022-08-01 17:02:46 +02:00
committed by GitHub
parent 250ffa49e4
commit e4e674df8f

View File

@@ -281,25 +281,27 @@ export const RequestUrlBar = forwardRef<RequestUrlBarHandle, Props>(({
send();
return;
}
if (!inputRef.current) {
return;
}
executeHotKey(event.nativeEvent, hotKeyRefs.REQUEST_FOCUS_URL, () => {
inputRef.current?.focus();
inputRef.current?.selectAll();
});
executeHotKey(event.nativeEvent, hotKeyRefs.REQUEST_TOGGLE_HTTP_METHOD_MENU, () => {
methodDropdownRef.current?.toggle();
});
executeHotKey(event.nativeEvent, hotKeyRefs.REQUEST_SHOW_OPTIONS, () => {
dropdownRef.current?.toggle(true);
});
}, [request.url, send]);
const handleGlobalKeyDown = useCallback(async (event: KeyboardEvent) => {
if (!inputRef.current) {
return;
}
executeHotKey(event, hotKeyRefs.REQUEST_SEND, () => {
send();
});
executeHotKey(event, hotKeyRefs.REQUEST_FOCUS_URL, () => {
inputRef.current?.focus();
inputRef.current?.selectAll();
});
executeHotKey(event, hotKeyRefs.REQUEST_TOGGLE_HTTP_METHOD_MENU, () => {
methodDropdownRef.current?.toggle();
});
executeHotKey(event, hotKeyRefs.REQUEST_SHOW_OPTIONS, () => {
dropdownRef.current?.toggle(true);
});
}, [send]);
const [lastPastedText, setLastPastedText] = useState<string>();