Change hotkey handling to capture phase

This commit is contained in:
Gregory Schier
2024-02-06 23:44:10 -08:00
parent a2a36ceb54
commit d668244f9b
3 changed files with 7 additions and 8 deletions

View File

@@ -91,7 +91,6 @@ export function GrpcEditor({
}, [alert, services, request.method, request.service]);
const reflectionUnavailable = reflectionError?.match(/unimplemented/i);
const reflectionSuccess = !reflectionError && services != null && request.protoFiles.length === 0;
reflectionError = reflectionUnavailable ? undefined : reflectionError;
return (
@@ -105,7 +104,7 @@ export function GrpcEditor({
placeholder="..."
ref={editorViewRef}
actions={[
<div key="reflection" className={classNames(!reflectionSuccess && '!opacity-100')}>
<div key="reflection" className={classNames(services == null && '!opacity-100')}>
<Button
size="xs"
color={

View File

@@ -52,7 +52,7 @@ export function GrpcProtoSelection({ requestId }: Props) {
await grpc.reflect.refetch();
}}
>
Add Files
Add File
</Button>
<Button
isLoading={grpc.reflect.isFetching}
@@ -139,7 +139,7 @@ export function GrpcProtoSelection({ requestId }: Props) {
<Link href="https://github.com/grpc/grpc/blob/9aa3c5835a4ed6afae9455b63ed45c761d695bca/doc/server-reflection.md">
Server Reflection
</Link>{' '}
. Please manually add the <InlineCode>.proto</InlineCode> files to get started.
. Please manually add the <InlineCode>.proto</InlineCode> file to get started.
</Banner>
)}
</VStack>

View File

@@ -112,11 +112,11 @@ export function useAnyHotkey(
}
currentKeys.current.delete(normalizeKey(e.key, os));
};
document.addEventListener('keydown', down);
document.addEventListener('keyup', up);
document.addEventListener('keydown', down, { capture: true });
document.addEventListener('keyup', up, { capture: true });
return () => {
document.removeEventListener('keydown', down);
document.removeEventListener('keyup', up);
document.removeEventListener('keydown', down, { capture: true });
document.removeEventListener('keyup', up, { capture: true });
};
}, [options.enable, os]);
}