Skip to content

Commit

Permalink
fix(mocks): Fix JSON editor losing focus
Browse files Browse the repository at this point in the history
  • Loading branch information
ademuk committed Dec 23, 2020
1 parent 5104b32 commit e64cb5e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/test/EditMockModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from "react";
import { useState } from "react";
import * as React from "react";
// @ts-ignore
import JSONInput from "react-json-editor-ajrm";
Expand All @@ -21,13 +21,11 @@ const EditMockModal: React.FC<EditStepProps> = ({
onClose,
onUpdateStep,
}) => {
const [returnValue, setReturnValue] = useState({});
const [returnValue, setReturnValue] = useState(
step.definition.return ? step.definition.return : {}
);
const [isValidJson, setIsValidJson] = useState(true);

useEffect(() => {
setReturnValue(step.definition.return ? step.definition.return : {});
}, [step.definition.return]);

const handleReturnValueChange = ({
error,
jsObject,
Expand Down Expand Up @@ -62,7 +60,7 @@ const EditMockModal: React.FC<EditStepProps> = ({
<div className="mt-2 flex">
<JSONInput
id="id"
placeholder={isValidJson ? returnValue : {}}
placeholder={step.definition.return}
theme="light_mitsuketa_tribute"
locale={locale}
width="100%"
Expand Down

0 comments on commit e64cb5e

Please sign in to comment.