diff --git a/src-web/components/GrpcEditor.tsx b/src-web/components/GrpcEditor.tsx index 5b511c64..2ebd01a1 100644 --- a/src-web/components/GrpcEditor.tsx +++ b/src-web/components/GrpcEditor.tsx @@ -174,7 +174,6 @@ export function GrpcEditor({ language="json" autocompleteFunctions autocompleteVariables - forceUpdateKey={request.id} defaultValue={request.message} heightMode="auto" placeholder="..." diff --git a/src-web/components/HttpRequestPane.tsx b/src-web/components/HttpRequestPane.tsx index e2f6d765..fe33fe0c 100644 --- a/src-web/components/HttpRequestPane.tsx +++ b/src-web/components/HttpRequestPane.tsx @@ -409,7 +409,6 @@ export function HttpRequestPane({ style, fullHeight, className, activeRequest }: ) : activeRequest.bodyType === BODY_TYPE_GRAPHQL ? ( { - const newBody = { query, variables: currentBody.variables || undefined }; - setCurrentBody(newBody); - onChange(newBody); - }; + const handleChangeQuery = useCallback( + (query: string) => { + setCurrentBody(({ variables }) => { + const newBody = { query, variables }; + onChange(newBody); + return newBody; + }); + }, + [onChange, setCurrentBody], + ); - const handleChangeVariables = (variables: string) => { - const newBody = { query: currentBody.query, variables: variables || undefined }; - setCurrentBody(newBody); - onChange(newBody); - }; + const handleChangeVariables = useCallback( + (variables: string) => { + setCurrentBody(({ query }) => { + const newBody = { query, variables: variables || undefined }; + onChange(newBody); + return newBody; + }); + }, + [onChange, setCurrentBody], + ); const actions = useMemo( () => [